2008-10-27, 02:00 AM
Russt Wrote:I'm not sure if this applies to coding as well, but on a graphing calculator, using xor (or any boolean operation) on integers is the same as converting them to binary and applying it to each respective digit.
E.g. 17 xor 54
17 = 10001_2
54 = 110110_2
10001_2 xor 110110_2 = 100111_2
100111_2 = 39
So 17 xor 54 = 39.
The variable swapping would go like this (not the actual code, but showing the process):
a = 17
b = 54
a = 17 xor 54 = 39
b = 39 xor 54 = 17
a = 39 xor 17 = 54
Anyway, Stereo's method accomplishes the same thing using addition/subtraction.
(Lemme guess, Fibonacci numbers?)
still don't get how xor works...
i don't get how xor sometimes add numbers and sometimes subtract them...
but i do get stereo's way though.

