static const int NumberOfSetBits[8] = { /* in nibble, half byte */
0, /* 0x0, b0000 */
1, /* 0x1, b0001 */
1, /* 0x2, b0010 */
2, /* 0x3, b0011 */
1, /* 0x4, b0100 */
2, /* 0x5, b0101 */
2, /* 0x6, b0110 */
3 /* 0x7, b0111 */
1 /* 0x8, b1000 */
2 /* 0x9, b1001 */
2 /* 0xA, b1010 */
3 /* 0xB, b1011 */
2 /* 0xC, b1100 */
3 /* 0xD, b1101 */
3 /* 0xE, b1110 */
4 /* 0xF, b1111 */
};
#define NumBytesInInt 4 /* assumes 32bit system */
int GetNumberOfSetBits(int anInteger)
{
uint8_t buf[NumBytesInInt ];
int i;
int count = 0;
memcpy(buf, &anInteger, sizeof(buf));
for (i=0; i> 4];
}
return count;
}