Run ❯
Get your
own Python
server
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
print(6 ^ 2 + 1) """ Bitwise XOR has a lower precedence than addition, and we need to calculate the addition first. The calculation above reads 6 ^ 3 = 5 More explanation: The ^ operator compares each bit and set it to 1 if only one is 1, otherwise (if both are 1 or both are 0) it is set to 0: 6 = 0000000000000110 3 = 0000000000000011 -------------------- 5 = 0000000000000101 ==================== Decimal numbers and their binary values: 0 = 0000000000000000 1 = 0000000000000001 2 = 0000000000000010 3 = 0000000000000011 4 = 0000000000000100 5 = 0000000000000101 6 = 0000000000000110 7 = 0000000000000111 """
5