
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