Skip to content

Divide in large numbers not working well #125971

@AminBidad1

Description

@AminBidad1

Bug report

Bug description:

I Write a code with large numbers( 10**18<n ) and I have understand that python in large numbers can't divide well.
for example:

n = 123140801928338636
print(n)  # 123140801928338636
print(n/2)  # 6.157040096416932e+16
print(int(n/2))  # 61570400964169320
from math import floor, ceil
print(floor(n/2))  # 61570400964169320
print(ceil(n/2))  # 61570400964169320
print(int(n/2)*2 == n)  # False

this bug can create security bugs in products.

CPython versions tested on:

3.12

Operating systems tested on:

Linux, Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions