The first approach to computing parity is doing xor operation on every bit. - This was simple to understand. An enhancement to that is to drop the lower bit and keep inverting parity till the number becomes 0 ie
While loop till number is greater than 0
1) parity = parity^1
2) number = number & (number-1)
How does this work? It is a little more difficult to grasp the idea of this method I guess.