1

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!

Sciguy77
  • 349
  • 6
  • 14

2 Answers2

6

The carat ^ is bitwise XOR. Imagine it like this:

>>> 8^3
11

8 in binary: 1000
3 in binary: 0011
8^3:         1011
A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76
1
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

Community
  • 1
  • 1
suhailvs
  • 20,182
  • 14
  • 100
  • 98