Stefan Krah <[email protected]> added the comment:
You can also set the decimal.FloatOperation trap to avoid accidental
errors:
>>> from decimal import *
>>> c = getcontext()
>>> Decimal(4.6) * 100
Decimal('459.9999999999999644728632120')
>>> c.traps[FloatOperation] = True
>>> Decimal(4.6) * 100
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
decimal.FloatOperation: [<class 'decimal.FloatOperation'>]
>>> Decimal("4.6") * 100
Decimal('460.0')
>>>
----------
nosy: +skrah
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40206>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com