@Jared:
There was no question it was just listed in the book as an assignment operator and I had not seen it used.... So your saying....
view plaincopy to clipboardprint?
a ^= b;
Is the same as....
view plaincopy to clipboardprint?
a = !b;
?
No, this is not what I am saying.
Try wikipedia or google for the ex-or operator and its related operations.
! is boolean operator, which will see only true and false values.
^ is ex-or operator which will modify the values.
Consider the two bits a and b , and will list down the truth table for them.
a b a^b
0 0 0
0 1 1
1 0 1
1 1 0
When both bits are 1, the resultant of their exors will be 0.
To learn more about this operator, I will suggest you to write small program which will take in two integers, and print their exor.
say lets assume n=5and m=9;
converitng n in binary gives 101
converting m in binary gives 1001
0 1 0 1
^ 1 0 0 1
------------
1 1 0 0=12 in decimal
so 5^9=12.
so a sample program can be written as
Which is equivalent to