0
Why print(5^4) shows 1
Why print(5^4) shows 1
4 ответов
+ 6
^ (xor) is a bitwise operator
This is what's happening under the hood:
000000100 = 4
000000101 = 5
^ will evaluate both values, if the bits are the same, 0 is returned, 1 vice versa.
000000001 = 1
+ 3
That helps. Thanks a lot
+ 2
Rik Wittkopp
Thank you for the compliment
+ 1
Terel
Great answer!