Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

longs appear to be converted to floats internally, silently losing precision #46

Closed
ajitgeorge opened this issue Nov 15, 2012 · 1 comment
Labels

Comments

@ajitgeorge
Copy link

ageorge@machine:~ (master)$ echo 1342647857257299304 | /grid/bin/jq .
1342647857257299200
ageorge@machine:~ (master)$ ipython
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
Type "copyright", "credits" or "license" for more information.

IPython 0.12.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: float(1342647857257299304)
Out[1]: 1.3426478572572992e+18
@stedolan
Copy link
Contributor

Yep. Doubles actually, so we've enough precision to hold 32 bit ints or milliseconds-since-1970 timestamps without loss of precision. The JSON spec doesn't specify number precision, so it's hard to tell what the correct behaviour is here, but most Javascript implementations use double precision.

You get the same output in the javascript console on chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants