Suppose we want to take a bitwise XOR of 5 and 12:
- Covert both numbers to binary; 5 is 0101 and 12 is 1100.
- Bitwise XOR performs an XOR operation bit by bit, starting from the first bit: 5 ^ 12 0 ^ 1 = 1 1 ^ 1 = 0 0 ^ 0 = 0 1 ^ 0 = 1
- Thus, 5 ^ 12 = 1001, which is 9.
With all the knowledge we required about atomics, let's hop back to our one billion count problem and see a possible fix.