Is there a rapid way of finding the number of bits set by an unsigned char?
unsigned char c1=63; //0x3f, binary: 0011 1111
unsigned char c2=67; //0x43, binary: 0100 0011
For c1, the answer I want is 6, and for c2 the answer I want is 3.
I'm going to be doing this calculation A LOT as part of an interative analysis program, and wondered if I should just set up some array like the following. Really would love a super rapid way of evaluating this number.
myarray(63) = 6;
myarray(67) = 3;
myarray(255) = 8;
Thanks in advance for your help.