Mail Archives: djgpp/1997/07/12/17:29:28
At 03:35 7/12/1997 +0100, you wrote:
>To find out if a value is odd or even all you have to do is check the first
>bit, bit 0.
That wasn't the question. The original poster wanted to find whether there
were an odd or even number of *1 bits* in an int (wanted to know its
parity). Ie, this number:
01110001010111001101010111001010b
has 17 1-bits in its binary representation, hence it has odd parity. Even
though it is an even number.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -