Can someone explain how this works?
#define BX_(x) ((x) - (((x)>>1)&0x77777777) \
- (((x)>>2)&0x33333333) \
- (((x)>>3)&0x11111111))
#define BITCOUNT(x) (((BX_(x)+(BX_(x)>>4)) & 0x0F0F0F0F) % 255)
Clarification:
Ideally, the answer will start something along the lines of:
The macro: "BX_" subtracts three values from the passed in number.
These three values represent:
- XXXXX
- YYYYY
- ZZZZZ
This allows the BITCOUNT() to work as follows...
Cheers,
David