sness
blog of sness
Thursday, March 03, 2011
Bit Twiddling Hacks
Bit Twiddling Hacks
: "Swapping values with XOR
#define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))
This is an old trick to exchange the values of the variables a and b without using extra space for a temporary variable."
Newer Post
Older Post
Home