Skip to content

% operator output wrong numbers #94303

Closed as not planned
Closed as not planned
@Yusuf-ASM

Description

@Yusuf-ASM

Remainder operator in python outputs wrong answer with negative numbers.
Example -latest available version 3.10.5 / os windows 10 - :

print(-24%-5)
print(-24%5)
print(24%-5)

The output

4
-4
1
-1

The correct output should be

4
-4
-4
4

Screenshot 2022-06-26 144913

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