[issue40206] Multiplying 4.6*100 will result in 459.99999999999994

Rémi Lapeyre report at bugs.python.org
Mon Apr 6 12:08:25 EDT 2020


Rémi Lapeyre <remi.lapeyre at henki.fr> added the comment:

@Steven Yes that's true, I only meant that in the context of the issue where only the multiplication is used. FWIW Fraction also would have issues with e.g. trigonometric functions right?


@ahmad, that's because you did Decimal(4.6) which first parse 4.6 as a float then call Decimal() with the result. You need to use Decimal('4.6') to avoid the parser reading 4.6 as a float. Have a look at the tutorial Eric Smith linked, the documentation of decimal and the response from Steven D'Aprano for more information.

----------

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


More information about the Python-bugs-list mailing list