Alternatively you can do:
a ^= b;
b ^= a;
a ^= b;
Which uses less energy because the bitwise operators do not use the intermediate/interbit carry.