[algogeeks] Re: Intuitive Understanding of XOR Operation

2011-06-21 Thread sav
An interesting fact about XOR: a = 1 b = 2 a = a ^ b b = a ^ b a = a ^ b The code above swaps 'a' and 'b' without the need of a third receipt. Magic! I'm sure this is pretty well known but in my case it really helped clearing my sight on this matter. The father of pragmatism (Charles S.

[algogeeks] Re: Intuitive Understanding of XOR Operation

2011-06-14 Thread Don
It is important to remember that xor is a bitwise operator, so x ^= y affects the individual bits of x based on the bits in y. Think of xor as a bitwise not-equal operator. The expression a = x ^ y Will set the bits of a to true if the corresponding bits of x and y are not equal. Thus the xor