I understand the idea and concept of XOR outside of code. But I wanted an easy explanation when it's used in code. Let me give you a few examples of what I'm having trouble understanding.
Say we wanted to Swap internet values in C++ with out using a third temp variable and by using XOR, like so:
int a = 1;
int b = 3;
int *x = &a;
int *y = &b;
*x ^= *y;
*y ^= *x;
*x ^= *y;
Now I understand that *x ^= y
translates to *x = *x ^ *y
But I just need to understand one line only to understand the rest. Basically, in *x = *x ^ *y
why is *y always being set to *x in order to being the swap sequence? (Or am I getting that part wrong too?) How is *y being exclusively chosen and on what criteria?