Toggle the ith bit - flip between states with XOR!
To toggle (flip) the ith bit of a number, use XOR with a mask:
XOR with 1 always flips the bit. This is perfect for toggles!