Coffee Break: Swapping Two Values Without Involving a Third One

Everybody knows the XOR bitwise operator. It returns 1 for every couple of bits that don’t match, 0 otherwise. What not everybody may be aware is a curious feature of it: it may serve to swap integer values (char, short, int, long long or their unsigned versions). Let’s see: // shemp contains 01000001 and curly…

0