The thing about the “Use XOR to swap two variables” trick is that it’s a version of this solution which works for any two real numbers (or integers):
a = a - b
b = a + b
a = b - a
XOR is simply addition or subtraction modulo 2 for each bit, so making the above XOR looks like this: a = a ^ b
b = a ^ b
a = b ^ a