Bit Twiddling in C - Counting Bits
问题 I want to count the bits that are set in an extremely large bit-vector (i.e. 100,000 bits). What I am currently doing is using a pointer to char (i.e. char *cPtr) to point to the beginning of the array of bits. I then: 1. look at each element of the array (i.e. cPtr[x]), 2. convert it to an integer (i.e. (int) cPtr[x]) 3. use a 256 element look-up table to see how many bits are set in the given byte (i.e. cPtr[x]). It occurs to me that if I use a short int pointer instead (i.e. short int *