Add countTrailingZeros function
Patch by David Majnemer.