Skip to content

Bitwise OR returns incorrect decimal result in Python 3.13.5 #139031

@TheDJDavies

Description

@TheDJDavies

Bug report

Description:
When performing a bitwise OR operation between two integers, the result is incorrect.

Specifically:

print(789 | 123)  # Expected: 891, Actual: 895
print(bin(789 | 123))  # Outputs: 0b1101111111

Version:
Python 3.13.5 (installed globally on macOS 14.x, M1 architecture) although I seem to be getting the same issue on 3.11.6 which concerns me

The binary result 0b1101111111 corresponds to decimal 891, yet the interpreter returns 895.
This indicates a mismatch between the binary and decimal representations of the result.

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