[issue38024] adding or subtracting decimals

Karthikeyan Singaravelan report at bugs.python.org
Wed Sep 4 03:53:13 EDT 2019


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

Please include the text of the repl session in issue so that it would be easy to copy past and also more accessible. The issue is as below in the attached image. I guess this is due to floating point representation and has some possible solutions in this page : https://docs.python.org/3/tutorial/floatingpoint.html and https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate

$ python3
Python 3.8.0b4 (v3.8.0b4:d93605de72, Aug 29 2019, 21:47:47)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 17.00005 + 6169.90760
6186.907649999999
>>> from decimal import Decimal
>>> Decimal('17.00005') + Decimal('6169.90760')
Decimal('6186.90765')

----------
nosy: +xtreak

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


More information about the Python-bugs-list mailing list