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 vstinner
Recipients larry, lemburg, mark.dickinson, rhettinger, serhiy.storchaka, stutzbach, vstinner, vxgmichel
Date 2020-02-03.16:35:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580747712.0.0.1275697553.issue39484@roundup.psfhosted.org>
In-reply-to
Content
I compare nanoseconds (int):

>>> t=1580301619906185300

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

# int/float: float.__rtruediv__(int)
>>> abs(t - int(t/1e9 * 1e9))
84

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

# float/float: float.__truediv__(float)
>>> abs(t - int(float(t)/1e9 * 1e9))
84

=> int/int is less accurate than float/float for t=1580301619906185300


You compare seconds (float/Fraction):

>>> from fractions import Fraction as F
>>> t=1580301619906185300

# int / int
>>> float(F(t/10**9) * 10**9 - t)
88.5650634765625

# int / float
>>> float(F(t/1e9) * 10**9 - t)
-149.853515625

=> here int/int looks more accurate than int/float


And we get different conclusion :-)
History
Date User Action Args
2020-02-03 16:35:12vstinnersetrecipients: + vstinner, lemburg, rhettinger, mark.dickinson, larry, stutzbach, serhiy.storchaka, vxgmichel
2020-02-03 16:35:11vstinnersetmessageid: <1580747712.0.0.1275697553.issue39484@roundup.psfhosted.org>
2020-02-03 16:35:11vstinnerlinkissue39484 messages
2020-02-03 16:35:11vstinnercreate