bit count : Java Glossary

The number of = 1 bits in a number. Here are two ways to
calculate it. The collapsing partial parallel sums method looks horribly complicated
but it works 5 times faster than the classic method. Here
is the partial sum collapsing method:
Here
Here is an algorithm what works quickly when there are only a few bits turned on.