Mar-20-2019, 11:58 AM
To avoid errors of floating point object representation in memory, it is better to pass strings to Decimal class, e.g.
@vercetty92, why did you are still using Python 2.6? Constructor of Decimal class in current versions of Python, e.g. Python 3.7, could process floats directly (without errors as in your example).
python -c "from decimal import Decimal; print(Decimal('0.0000006') + Decimal('0.0000008'))"
. This likely should work in python2.6. @vercetty92, why did you are still using Python 2.6? Constructor of Decimal class in current versions of Python, e.g. Python 3.7, could process floats directly (without errors as in your example).