XOR Swap Explained Visually

from blog danangell.com/blog, | ↗ original
A common riddle-like question for programmers asks them to swap the values of two integers without a temporary intermediate value. There are two common solutions that I’m aware of, addition swap and XOR swap. Here’s what each looks like in C: void addSwap (unsigned int *a, unsigned int *b) { if (a != b) { *a = *a + *b; ...