BITCOUNT macro in C -
how can count how many 0 bits in variable? must use macro thist bitcount(x,c) x variable , c count of 0 bits in x
example: x = 00101001 , c = 5
a simple solution:
#include <limits.h>
#define bitcount(x,c) \ { \ int i; \ (c) = 0; \ ( = 0; < char_bit * sizeof(x); i++ ) \ (c) += ( (x) & ( 1 << ) ) == 0; \ }
Comments
Post a Comment