On Thu, Aug 8, 2019 at 11:34 PM Ronald Oussoren via Python-ideas <python-ideas@python.org> wrote: > > > > On 8 Aug 2019, at 12:22, Richard Musil <risa20...@gmail.com> 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. > > > It really doesn’t, both values have the same binary representation. See the > Python FAQ at > <https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate> > or the floating point section of the tutorial at > <https://docs.python.org/3/tutorial/floatingpoint.html#tut-fp-issues> for > more information. >
That depends on your definition of "matter". The JSON specification doesn't actually stipulate IEEE 64-bit floating point; it just defines the grammar. It'd be completely valid to use a JSON number to carry data from one Python script into another, where both ends use decimal.Decimal to store it. But if the value is going to be parsed into a float at the other end, then yeah, they're equivalent. 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/I4WVHTSE2RLJH3PKMYGRF3UJFBA3BTLZ/ Code of Conduct: http://python.org/psf/codeofconduct/