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.

Author mark.dickinson
Recipients larry, lemburg, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach, vstinner, vxgmichel
Date 2020-02-03.17:57:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580752674.72.0.755478183049.issue39484@roundup.psfhosted.org>
In-reply-to
Content
To be clear: the following is flawed as an accuracy test, because the *multiplication* by 1e9 introduces additional error.

# int/int: int.__truediv__(int)
>>> abs(t - int(t/10**9 * 1e9))
172

Try this instead, which uses the Fractions module to get the exact error. (The error is converted to a float before printing, for convenience, to show the approximate size of the errors.)

>>> from fractions import Fraction as F
>>> exact = F(t, 10**9)
>>> int_int = t / 10**9
>>> float_float = t / 1e9
>>> int_int_error = F(int_int) - exact
>>> float_float_error = F(float_float) - exact
>>> print(float(int_int_error))
8.85650634765625e-08
>>> print(float(float_float_error))
-1.49853515625e-07
History
Date User Action Args
2020-02-03 17:57:54mark.dickinsonsetrecipients: + mark.dickinson, lemburg, rhettinger, vstinner, larry, stutzbach, serhiy.storchaka, vxgmichel
2020-02-03 17:57:54mark.dickinsonsetmessageid: <1580752674.72.0.755478183049.issue39484@roundup.psfhosted.org>
2020-02-03 17:57:54mark.dickinsonlinkissue39484 messages
2020-02-03 17:57:54mark.dickinsoncreate