Intrinsic to count trailing zero bits in 64-bit integers?

前端 未结 1 352
时光取名叫无心
时光取名叫无心 2020-12-11 07:15

this is sort of a follow up on some previous questions on bit manipulation. I modified the code from this site to enumerate strings with K of N bits set (x is the current <

相关标签:
1条回答
  • 2020-12-11 07:40

    __builtin_ctz takes arguments of type unsigned int, which is 32-bits on most platforms.

    If long is 64 bits, you can use __builtin_ctzl which takes unsigned long. Or you can use __builtin_ctzll which takes unsigned long long - In this case you should use 1ULL << i instead of 1UL << i.

    0 讨论(0)
提交回复
热议问题