Jump to content

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...