home *** CD-ROM | disk | FTP | other *** search
- /****** BIT COUNTER *************/
- bit_count(x)
- {
- int n=0;
-
- if (x) do
- n++;
- while(x=x&(x-1));
- return(n);
- }/*******************************/
-
- /*
- ** The loop will execute once for each bit of x set, this is in average
- ** twice as fast as the shift/test method.
- */
-