Jump to content

python


Raja NI

Recommended Posts

  • 1 month later...

What's important with these operators, is that they perform Binary Arithmetic. So to understand it, you need to understand X and Y in Binary.

X (101)= 5
Y (011) = 3

^= Is the python bitwise XOR operator, and the result of XORing X and Y is the following
X ^= Y (XOR)
(110) = 6

Similarly |= is the Bitwise OR operator, and so
X |= Y (OR)
(111) = 7

And &= is the bitwise AND opereator, and so
X &= Y (AND)
(001) = 1

Each operation is applied to each digit in sequence.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...