How to find number of trailing 0s in a binary number?Based on K&R bitcount example of finding 1s in a binary number i modified it a bit to find the trailing 0s.
On GCC on X86 platform you can use __builtin_ctz(no) On Microsoft compilers for X86 you can use _BitScanForward
__builtin_ctz(no)
_BitScanForward
They both emit a bsf instruction