View Full Version : ^ operator
08-25-2010, 08:56 PM
the statement did not return a syntax error, but a number, after doing some more ^ operations i can't see the relation between the numbers i use and the answer it gives me.
08-25-2010, 09:10 PM
08-25-2010, 09:28 PM
Its simply a bit XOR.
It returns a result where each bit in the left side that matches on the right side is inverted. Just on a nibble calculation since I don't want to type all the 0's.
5 = 0101
4 = 0100
5 ^ 4 = 1
The 'leftmost' bit in the above (2^(3-1), where this one is actually the exponent) is 1 in both the 5 and the 4, so its inverted to 0. The rightmost one (2^(1-1)) is 1 only in the 5 and not in the 4, so it remains untouched. Simple as that.
Dang, beaten. That's a good link too, all its missing is the not (since I don't think derivatives like NAND exist in most languages), which is simply a unary ~.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.