On Fri, Nov 15, 2019 at 4:04 AM <awesomecr...@gmail.com> wrote:
>
> Does decimal make this:
> 4.1 + 0.1
> produce 4.2 instead of 4.19999999999998?

The decimal module means that Decimal("4.1") is equal to 41/10 rather
than 2308094809027379/562949953421312, and Decimal("0.1") is equal to
1/10 rather than 3602879701896397/36028797018963968. But in your
source code, if you type 4.1, you are asking for the floating-point
value 2308094809027379/562949953421312, just as if you say "hello" you
are asking for a Unicode string containing those five characters/code
points.

The problem here is not with addition, but with whether or not you
have the number you think you do. So to get a different result, you
have to start with different values.

ChrisA
_______________________________________________
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/CMY6MGTHILXXZE323S2J6TU7OD7JQSFX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to