/****** * bit_ops.c * * sample bit operations in C * * $ make bit_ops * gcc -march=athlon64 -O2 bit_count.c -o bit_count * $ ./bit_ops * * *******/ #include int bitcount(char x){ int count; for (count=0; x != 0; x>>=1){ if (x & 01){ count++; } } return count; } int bittest(char* x){ } int main(){ char a = 'a'; char_bits b; int i; printf("'%c' is ascii '%i' ('%o' octal) which has '%i' 1's in binary. \n", a, (int)a, (int)a, bitcount(a)); b = 7; for (i=0; i<8; i++){ } }