We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b87d51 commit 9846e3cCopy full SHA for 9846e3c
ultimatepython/syntax/bitwise.py
@@ -40,6 +40,11 @@ def main():
40
result_right_shift = a >> 1 # Binary: 0010 (Decimal: 2)
41
assert result_right_shift == 2
42
43
+ # Note that bitwise shifts have lower precedence than arithmetic operations
44
+ # https://docs.python.org/3/reference/expressions.html
45
+ result_right_shift_with_addition = a >> 1 + 1 # Equivalent to a >> (1 + 1)
46
+ assert result_right_shift_with_addition == 1 # Binary: 0001 (Decimal: 1)
47
+
48
49
if __name__ == "__main__":
50
main()
0 commit comments