Reputation: 1007
Can I make a function int bitParity(int x) that returns 1 if x contains an odd number of 0's using only these operators? ! ~ & ^ | + << >>
Upvotes: 0
Views: 188
Reputation: 2148
Hey, it was exactly three clicks. google -> 1.st result - wiki/Parity_bit -> external link -> http://graphics.stanford.edu/~seander/bithacks.html#ParityNaive
Upvotes: 2