I've been searching and found that the ^= operator is the same as running the function ixor(a,b,). However this returns the sum of a and b, so then how is ^= different than +=?
Thanks!
I've been searching and found that the ^= operator is the same as running the function ixor(a,b,). However this returns the sum of a and b, so then how is ^= different than +=?
Thanks!
The carat ^
is bitwise XOR. Imagine it like this:
>>> 8^3
11
8 in binary: 1000
3 in binary: 0011
8^3: 1011
x ^ y
Does a bitwise exclusive or. Each bit of the output is the same as the corresponding bit in x if that bit in y is 0, and it's the complement of the bit in x if that bit in y is 1. source