On 08/08/2019 11:22, Richard Musil wrote:
I have found myself in an awkward situation with current (Python 3.7) JSON 
module. Basically it boils down to how it handles floats. I had been hit on 
this particular case:

In [31]: float(0.6441726684570313)
Out[31]: 0.6441726684570312

but I guess it really does not matter.

Well, yes it does. It's pretty much the whole of the matter. Unless you get lucky with values, floats are inherently imprecise. The number you are playing with is apparently 0.64417266845703125 as an IEEE float representation. It happens that Python rounds down ("rounds to even" is the statement in the documentation) when it displays this.

Essentially you are not getting the precision you think you are getting.

--
Rhodri James *-* Kynesim Ltd
_______________________________________________
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/3GHTTT7FYFYMKQSNQCL4ZN2HIDZ3GLAU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to