On 2019-11-14 17:10, Brett Cannon wrote:

On Thu, Nov 14, 2019 at 9:04 AM <awesomecr...@gmail.com <mailto:awesomecr...@gmail.com>> wrote:

    Does decimal make this:
    4.1 + 0.1
    produce 4.2 instead of 4.19999999999998?


Yes, see https://docs.python.org/3/library/decimal.html#module-decimal.

If you're talking about literal 4.1 and literal 0.1 in the code, then no.

It would be:

from decimal import Decimal
print(Decimal('4.1') + Decimal('0.1'))

There have been suggestions in the past to add a suffix, e.g. 4.1d + 0.1d, given that the 'decimal' module is in the stdlib.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/C22DFDLKXDPP6EBTNH6LZFNXSJUQFV7W/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to