4 ms·
> checks if the values are equal Not the values (the values being equal doesn't break the trick), but the pointers. That is, if you use the XOR trick to swap a
by FabHK 6y ago
> checks if the values are equal
Not the values (the values being equal doesn't break the trick), but the pointers. That is, if you use the XOR trick to swap a value with itself, then it will be set to zero, instead.
As if you had written:
x ^= x
x ^= x
x ^= x
Yeah, now x would be zero, not itself.