Do you want the least significant 1 bit set?  Then use trailing_zeros(x). 
(I use that a lot for packing floating point values, which are right 
justified in the word (if you consider the msb as being the rightmost bit).
If you want the most significant 1 bit set, then leading_zeros(x) (which 
other people have already mentioned).

On Thursday, August 11, 2016 at 7:48:08 PM UTC+2, jw3126 wrote:
>
> I have a bitstype and want to know the number of ones in its bit 
> representation as well as the first bit. How to accomplish these in a 
> performant way?
>

Reply via email to