The way I explain XOR to people is a light controlled by two switches. For instance, a light over some stairs, with upstairs and downstairs switches. Most people then realise they've been dealing with XOR for ages, even if they're not computery.
If younger me, learning some computer science in Uni had seen this write up when learning Boolean logic, I absolutely would've needed a lie down. Very keen to give this a read later, thanks!
Thanks! Will be useful reference when explaining students the value of XOR in cryptography. I'd probably explicitly add in cryptography section that its result doesn't bias towards 0 or 1, which is what makes it good for combining plaintext with the key stream.
Very nice. Recently I used the fact that if two vectors are binary quantized (the bit is just the direction), the popcount of (v1 XOR v2) / numbits is proportional to their cosine distance. XOR keeps appearing everywhere, really deserved a writeup.
Comments
"How do you swap 2 8-bit values without using any form of temporary storage"
If anyone's wondering :)
B = A XOR B
A = A XOR B
B = A XOR B
I’ve used XOR in digital circuits for ages. Years before I discovered their usefulness in software.