OpenCL has a builtin function clz() to count the number of leading zeros of a long, int, etc. but nothing similar seems to be present for counting the number of trailing zeros. I've not been able to find any way to do this, other than just manually re-implementing of course. What is the proper way to do this?
x & -x
leaves one least significant 1-bit. To get its position you can try something like:
32 - clz(x & -x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With