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

Large integer are changed, even if only other parameter are touched #162

Open
ujaehrig opened this issue May 9, 2017 · 2 comments
Open

Comments

@ujaehrig
Copy link

ujaehrig commented May 9, 2017

When running an assign on a JSON with a large integer, the integer is changed. This might probably be caused by handling it as a double?

Example:

echo '{"id":6000000000000002181,"flag":false}' | rq --format=compact 'assign { "flag":true }'

results in:

{"flag":true,"id":6000000000000002048}
@ujaehrig ujaehrig changed the title Large integer handling is wrong Large integer are changed, even if only other parameter are touched May 9, 2017
@dflemstr
Copy link
Owner

Hey @ujaehrig, yes this is due to the fact that Javascript only supports representing numbers up to 2^53-1 (usually encoded as a double but not necessarily). Not sure how to solve this tbh...

@ujaehrig
Copy link
Author

Yes, I checked the specs in the meantime and saw that JSON has only the double precision number type. My example had used Java-Jackson as JSON processor which can also handle long ints.
Nevertheless, it's unfortunate, that rq changes the value, even it's not touched directly. Maybe a warning (something like "int number too large" or "int number precision loss") could be the first solution?

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

No branches or pull requests

2 participants