3 ms·
you don't have to use xor, this will work and perhaps easy to follow /* assume x = 5, y = 10; */ x = x + y; /* x = 5 + 10 = 15*/ y = x - y; /* y = 15 -
by sushantsharma 16y ago
you don't have to use xor, this will work and perhaps easy to follow
/* assume x = 5, y = 10; */
x = x + y; /* x = 5 + 10 = 15*/
y = x - y; /* y = 15 - 10 = 5 */
x = x - y; /* x = 15 - 5 = 10 */
- mfukar 16y agoUntil overflow occurs. Xor is safer.