cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

binghy
Adept II

1 bits count in a variable

Jump to solution

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

Tags (2)
0 Likes
1 Solution

Accepted Solutions
boxerab
Challenger

Re: 1 bits count in a variable

Jump to solution

Yes, indeedy:  popcount

popcount

View solution in original post

0 Likes
2 Replies
boxerab
Challenger

Re: 1 bits count in a variable

Jump to solution

Yes, indeedy:  popcount

popcount

View solution in original post

0 Likes
binghy
Adept II

Re: 1 bits count in a variable

Jump to solution

You saved me. Appreciate.

0 Likes