cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

binghy
Adept II

1 bits count in a variable

Hi everybody,

I was wondering if there was an integer function to count the number of 1 bits contained in a variable.

I saw the "clz" function allows to count the number of "leading 0 bits". If it was set as a function to count the number of "all the 0 bits", then I could obtain the number of 1 bits just by subtraction.

No other similar funtion, nor in the OpenCL specs nor in the Blas library.

Any suggestions?

Thanks in advance

Marco

0 Likes
1 Solution
boxerab
Challenger

Yes, indeedy:  popcount

popcount

View solution in original post

0 Likes
2 Replies
boxerab
Challenger

Yes, indeedy:  popcount

popcount

0 Likes

You saved me. Appreciate.

0 Likes