Raja NI 0 Posted April 9 Report Share Posted April 9 Hi x=5 y=3 why x^=y => 6 why x l=y => 7 why x &= y => 1 Quote Link to post Share on other sites

Funce 42 Posted May 14 Report Share Posted May 14 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. Quote Link to post Share on other sites

## Recommended Posts

## Join the conversation

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