[Developers] Problem writing floating point value twice (or "What value of epsilon does MQL use?")

Scott Meyer sm at metaweb.com
Wed Jul 29 21:43:51 UTC 2009


Warren Harris wrote:
> 
> On Jul 29, 2009, at 2:19 PM, Tom Morris wrote:

>> If I convert my Python float to a string and truncate the string, will
>> the JSON marshalling done by python-api and lower layers do the right
>> thing or does it need to be in float format as it goes into the pipe?
> 
> The issue here is partly related to how our json library parses your
> float, and how python formats it before sending it to our graph
> database. But without a careful analysis of all possible code paths, it
> seems unlikely that you'd be able to work around this in all cases.

How about allowing strings for floating point values.  If you say

   "value": 3.456,

You get something written to the database that is "relatively close"
to "3.456".  We make a best effort to deal with floating point
rounding problems, best being not very good as we're at the mercy
of a number of JSON libraries.  However if you say:

   "value": "3.456",

we write "3.456" (exactly) into the database after verifying that it
does parse as a float.

-Scott


More information about the Developers mailing list