[New-bugs-announce] [issue43291] elementary multiplication by 0.01 error

Tony report at bugs.python.org
Sun Feb 21 20:37:01 EST 2021


New submission from Tony <tonys at lords.com>:

on the >>> prompt type:
>>>717161 * 0.01
7171.610000000001

the same goes for
>>>717161.0 * 0.01
7171.610000000001

You can easily find more numbers with similar problem:
for i in range(1000000):
    if len(str(i * 0.01)) > 12:
        print(i, i * 0.01)

I am sure, that this problem was found before and circumvented by:
>>>717161 / 100
7171.61

but this is hardly the way, one wants to rely on the code.

This is the python version I use:
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32

----------
messages: 387485
nosy: tonys_0
priority: normal
severity: normal
status: open
title: elementary multiplication by 0.01 error
type: behavior
versions: Python 3.7

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


More information about the New-bugs-announce mailing list