What is the fastest way to count all set bits?
The number from which I am counting bits is from 1<=n<2^63, only positive values.
For now I use bitset from the library and it is pretty fast, but if there is any faster option I would like to know.
In the worst case scenario I have over 1 billion iterations, so I am looking a way to speed it up.
This is the part of my loop where I am counting the setted bits:
if (std::bitset<64>(currentNumber).count() == numofOnes)
++counter;