Explanation: XOR of a number with itself is 0, and XOR with 0 gives the number itself. So, all duplicates cancel out.
Explanation: The least significant bit is 1 for odd numbers and 0 for even numbers.
Explanation: Powers of 2 have only one bit set. Subtracting 1 flips all bits after that set bit.
Explanation: -n is the two's complement of n, which inverts all bits and adds 1.
Explanation: n-1 has all bits same as n from left until the rightmost set bit, which becomes 0, and all bits to its right become 1.
Explanation: Uses the property (AB)B = A and A^A = 0.