Swapping Values with XOR

Viewed 400

What is the difference between these two macros?

#define swap(a, b)    (((a) ^ (b)) && ((a) ^= (b) ^= (a) ^= (b)))

Or

#define swap(a, b)    (((a) ^ (b)) && ((b) ^= (a) ^= (b), (a) ^= (b)))

I saw the second macro here but couldn't understand why it wasn't written like the first one? Is there a special reason that I missed?

3 Answers
Related