[New-bugs-announce] [issue25129] suboptimal floating-point floor division

Antoine Pitrou report at bugs.python.org
Tue Sep 15 19:28:03 CEST 2015


New submission from Antoine Pitrou:

>>> (78*6e-8) / 6e-8
78.0
>>> (78*6e-8) // 6e-8
77.0

Note this doesn't make divmod() wrong:

>>> q, r = divmod(78*6e-8, 6e-8)
>>> q, r
(77.0, 5.999999999999965e-08)
>>> r < 6e-8
True
>>> q * 6e-8 + r == 78*6e-8
True

But, still, it is somewhat of an oddity to not return the real quotient when it is an exact integer.

Note this came from a Numpy issue where Numpy actually shows better behaviour:
https://github.com/numpy/numpy/issues/6127

----------
components: Interpreter Core
messages: 250786
nosy: mark.dickinson, pitrou, tim.peters
priority: normal
severity: normal
status: open
title: suboptimal floating-point floor division
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25129>
_______________________________________


More information about the New-bugs-announce mailing list