This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong division calculation for numbers more than 16 digits
Type: Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: abahar1996, steven.daprano, zach.ware
Priority: normal Keywords:

Created on 2021-06-14 14:04 by abahar1996, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
big_number.py abahar1996, 2021-06-14 14:04 An example of division of big numbers in Python 3.9.5
Messages (3)
msg395798 - (view) Author: Abbas Baharforoosh (abahar1996) Date: 2021-06-14 14:04
Hi
For big numbers (more than about 16 digits), python wrong calculate division, but calculating mod (%) is correct.

I write a sample code of manual division in file.

Thanks
msg395807 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2021-06-14 15:30
The `/` operator does true division, which means the result will be a `float` rather than an `int`.  When the resultant float is large enough, precision will be lost.

You can use the `//` operator for floor (integer) division, where the result will remain as an integer.
msg395825 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2021-06-14 17:51
Also please read this:

https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88585
2021-06-14 17:51:07steven.dapranosetnosy: + steven.daprano
messages: + msg395825
2021-06-14 15:30:42zach.waresetstatus: open -> closed

nosy: + zach.ware
messages: + msg395807

resolution: not a bug
stage: resolved
2021-06-14 14:04:18abahar1996create