Best algorithm to count the number of set bits in a 32-bit integer?
- by Matt Howells
8 bits representing the number 7 look like this:
00000111
Three bits are set. What is the best algorithm to determine the number of set bits in a 32-bit integer?