C examples for Operator:Bit Operator
Count 1 bits in integer
#include <stdio.h> int bitcount(unsigned x); int main(void){ printf("%d\n", bitcount(011111)); return 0;/* w ww. j a v a 2 s . c o m*/ } int bitcount(unsigned x) { int b; for (b = 0; x != 0; x &= (x - 1)) b++; return b; }