Skip to content

XOR (^) and POWER (**) in formula lead to surprising result #142194

@SergeyKabantsov

Description

@SergeyKabantsov

Bug report

Bug description:

print(3^2)
print(2**3 - 2)
print(3^2 + 2**3 - 2) # expected 7
assert 3^2 + 2**3 - 2 == (3^2) + (2**3 - 2) # expected OK
1
6
11   
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    assert 3^2 + 2**3 - 2 == (3^2) + (2**3 - 2)
AssertionError

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions