The XOR operator (^) compares two numbers bit by bit. The result has a 1 when the bits differ, and 0 when they're the same.
Example: . In binary, and . Comparing: , , , . Result: .
XOR has a magic property: and . This makes XOR perfect for finding unique elements, toggling bits, and swapping values without a temporary variable.