Glen, XOR means Exlusive OR. Example:
00110 BITXOR 10011 yields 10101
because 0 XOR 1 = 1, 0 XOR 0 = 0, 1 XOR 0 = 1, (here's the tricky one) 1 XOR 1 = 0 (because it needs to be exclusive), and 0 XOR 1 = 1
1 0 1 0 1
The example is still hard to read, even when you understand XOR, because it is a counter-intuitive approach. It is, however, frighteningly clever.
- Charles 'Exclusive' Barouch
Glenn W. Paschal wrote:
Ok, I love brainteasers, but to be honest, I don't see how this works, possibly because I am one of those who has never used BITXOR, and so don't readily understand it. Please elaborate!
Thanks, --Glenn.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Glenn Herbert Sent: Friday, February 13, 2004 2:25 PM To: U2 Users Discussion List Subject: RE: Swap array values? In UV
*lol* i agree it's nasty and not readily obvious as to it's intent, but that wasn't the question posed...
sometimes it's just to exercise the mind
At 02:36 PM 02/13/2004, you wrote:
I understand why this works, but honestly, that's nasty.
array(x)=BITXOR(array(x),array(y)); array(y)=BITXOR(array(y),array(x)); array(x)=BITXOR(array(x),array(y));
No temp variable used.
-- u2-users mailing list [EMAIL PROTECTED] http://www.oliver.com/mailman/listinfo/u2-users