//KM 2018 03 23: getting lots of form spam; screen out dates before 2000 (book publication date) Neat XOR trick | Byte Craft Limited

Neat XOR trick

This is a neat trick using XOR, the most mysterious of the logical operators. Best of all for embedded, it requires no temporary locations.

//swap two values in place
if(x < y)
  x = x ^ y;
  y = y ^ x;
  x = x ^ y;

Et voila!