re: Swapping two numbers, w/o a temp variable VIEW POST

TOP OF THREAD FULL DISCUSSION
re: That's why you usually use XOR for the swap trick :) a^=b; // a' = (a^b) b^=a; // b' = b ^ (a') = b ^(a^b) = a a^=b; // a'' = a' ^ b' = (a^b)^...
 

Yeah, but not in real code! I'd prefer it were readable over assigning one extra variable. You've got to find some specific conditions to make this the better code to use!

code of conduct - report abuse