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: Division Precision Problem
Type: behavior Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, eric.smith, kulopo
Priority: normal Keywords:

Created on 2019-04-18 08:25 by kulopo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg340471 - (view) Author: kulopo (kulopo) Date: 2019-04-18 08:25
>>> a=224847175712806907706081280
>>> b=4294967296
>>> assert int(a*b/b)==int(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError
(a can be exact divided by b)
msg340472 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-04-18 08:30
This is the expected and correct behavior. Python's float are IEEE 754 floats, https://en.wikipedia.org/wiki/IEEE_754. IEE 754 have a limited precision. 224847175712806907706081280 / 4294967296 is not exactly dividable under IEEE 754 semantics. 

>>> a=224847175712806907706081280
>>> b=4294967296
>>> a/b
5.235131264496755e+16
msg340473 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-04-18 08:32
Also see https://docs.python.org/3/tutorial/floatingpoint.html for some Python-specific details.
History
Date User Action Args
2022-04-11 14:59:14adminsetgithub: 80836
2019-04-18 08:32:19eric.smithsetnosy: + eric.smith
messages: + msg340473
2019-04-18 08:30:33christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg340472

resolution: not a bug
stage: resolved
2019-04-18 08:25:15kulopocreate