Wednesday, September 30, 2015

Cool way to count bits

Count the set bits in a number.  Pretty cool.

for( count = 0; value != 0; count++ )
{
   value &= value – 1;

}


No comments: