Finding trailing 0s in a binary number

前端 未结 7 861
渐次进展
渐次进展 2021-01-06 00:32

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.

7条回答
  •  执念已碎
    2021-01-06 01:30

    On GCC on X86 platform you can use __builtin_ctz(no) On Microsoft compilers for X86 you can use _BitScanForward

    They both emit a bsf instruction

提交回复
热议问题