I have the following problem with the xor ( ^) operator in python. I have two binary numbers, let a = 10100111and b = 10000000. When I use the xor operator,
print (10000000 ^ 10100111)
I get the result 166671 instead of 00100111. However, when I use
print (100 ^ 101)
I get the corresponding result in binary 1 (001). Even if I use
print int(a) ^ int(b)
I am still getting the result 166671.
Questions:
I am running Python version 2.7.2.
source
share