1. ## Question about an operator

Hello.
In the following code, which can be found in this tutorial, what does the operator ^= mean?

Code:
`#define SWAP(a, b)  a ^= b; b ^= a; a ^= b;`

2. ^ is the symbol for the logical operator XOR (exclusive OR)

a ^= b is the same as a = a ^ b

3. Thanks. Appreciate it.
So it means

a equals exclusively a or exclusively b
Interesting...
So why then does it repeat the same thing two times, basically stating

a equals exclusively a or exclusively b
b equals exclusively a or exclusively b
(and then it says it again)
a equals exclusively a or exclusively b
?

4. stupid question, what is an exclusive or?

5. Originally Posted by Mediah-ikthya
stupid question, what is an exclusive or?
I was going to say that there aren't any stupid questions, but to be honest, after spending years on a forum on computer security(Not this one), I have to say that there are.

Yours, however, isn't.

XOR is an operator(So to speak) that is part of the boolean logic system invented by George Boole.

You should really look it up, as it's a much too complex subject for me to explain in a forum post, but let it suffice to say that the above code, due to the nature of the XOR operator, swaps the values. Also, boolean logic is pretty much the base of all circuitry ever made. Your computer is based on this stuff.

6. Originally Posted by IceDane
I was going to say that there aren't any stupid questions, but to be honest, after spending years on a forum on computer security(Not this one), I have to say that there are.
Sadly there are stupid questions, I work in customer service and deal with them on a daily basis. I think that there people who simply should not be allowed to have computers. I had to try and explain to a woman that if her computer was displaying another language that had to do with the settings on her computer and it had nothing to do with her monitor.

But all that aside

So I did google it, which is what I probably should have done in the first place, and all I can say is what a neat function! I'm a complete noob slowly working my way through my first C++ class. I've just mastered the += function and the basic concept of switches.

I thought I would start haunting programming boards to see what I can learn. I always seem to do better when I get in way over my head and am forced to sink or swim.

7. Originally Posted by Mediah-ikthya
I always seem to do better when I get in way over my head and am forced to sink or swim.