[New-bugs-announce] [issue42148] floating point representation issues

Andrea Tuccia report at bugs.python.org
Sun Oct 25 12:49:56 EDT 2020


New submission from Andrea Tuccia <andrea at tuccia.it>:

I'm noticing some floating point representation precision issues that occurs on all versions and platforms:

>>> 277*0.1
27.700000000000003
>>> 1.2-1.0
0.19999999999999996
>>> import numpy as np
>>> np.double(277*0.1)
27.700000000000003
>>> np.double(1.2-1.0)
0.19999999999999996
>>> np.longdouble(277*0.1)
27.700000000000002842
>>> np.longdouble(1.2-1.0)
0.19999999999999995559

Verified with python 2.7 to 3.8. On x86 (i386 and amd64) and ARM (32 and 64 bits). It does not occur in C, LUA, Perl, ...

----------
components: Interpreter Core, Library (Lib)
messages: 379589
nosy: atuccia
priority: normal
severity: normal
status: open
title: floating point representation issues
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42148>
_______________________________________


More information about the New-bugs-announce mailing list