There are perhaps 5% of the population that simply *can't* think. There are another 5% who *can*, and *do*. The remaining 90% *can* think, but *don't*.
I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
Education Sponsors
I am being sponsored by A-Writer! If you ever need help with essay writing, look no further than A-Writer! They will help you with your writing in as quickly as 3 hours!
Count the number of bits set -
int count_set_bits( int n )
{
int count = 0;
while ( n ) {
++count;
n &= (n-1);
}
return count;
}
The loop runs only as many times as there are bits set in n.
Reply To This Comment