Assume the operator a $ b has 2 identities E1 and E2.

Then for all a, a $ E2 = a,

and for all b, E1 $ b = b.

So, E1 $ E2 = E1,

and E1 $ E2 = E2.

making E1 = E2.

So, there is still only one unique identity.

]]>You’ve got me intrigued why the C# version doesn’t work.

]]>test

In C++ the code is equivalent to ((a ^= b) ^= c) ^= d (which is not valid C#)

In C# the code is equivalent to a ^= (b ^= (c ^= d))

]]>a^=b^=a^=b;

I think you’ll like it. Note that the same operation also works on large memory-mapped structures such as arrays (or screens). Interestingly, in C# you have to write it as a^=b;b^=a;a^=b; or it renders one of the variables to zero. Something to do with compiler optimization, I think. Anyway, it’s a useful trick… a little bit write-only, but useful nonetheless.

]]>http://marathoncode.blogspot.com.br/2012/02/tutorial-sobre-xor.html ]]>