On Thu, Aug 8, 2019 at 4:01 PM Steven D'Aprano wrote:
> In [31]: float(0.6441726684570313)
> > Out[31]: 0.6441726684570312
>
> The call to float() there is a no-op, because the literal 0.64417... is
> already compiled to a float before the function is called. Calling
> float() on a float does nothing. So the problem here lies *before* you
> call float(): floats only have finite precision, and they use base 2,
> not 10, so there are many decimal numbers they cannot represent. And
> 0.6441726684570313 is one of those numbers.
Here's the same idea, expressed differently:
>>> 0.6441726684570313
0.6441726684570312
>>> 2.000
2.0
--
Jonathan
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/F2CUWGHTLFUYRNYKF34MSXROXGLOWEQP/
Code of Conduct: http://python.org/psf/codeofconduct/