-
Notifications
You must be signed in to change notification settings - Fork 18
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
Handle large integer values losslessly? #152
Comments
That is because
|
@MiSawa Thanks for the reply! For me personally the general principle that I'd prefer in most contexts is that the tool should not change values that the user did not specifically ask to be transformed. I just learned that this is what jq has done for numeric values for a couple of years in the master branch (although not in the latest official release). For example: $ jq <<< "0.0001000"
0.0001000
$ jq <<< '18276318.736187263187638172'
18276318.736187263187638172
$ jq <<< '10000000000000000000000000000000000000012'
10000000000000000000000000000000000000012 (gojq gives the same result for the integral value, but drops the trailing zeros on the first example, and rounds the second.) |
Ah interesting, they have decimal number calculation introduced, so it's not just preserve user's input as a string but actually treat them as a decimal number with precision given. https://github.com/stedolan/jq/tree/master/src/decNumber $ ./jq <<< '0.1010e2'
10.10 |
Currently these are formatted with scientific notation (in some cases lossily). For example (from a user JSON object from the Twitter API):
Is this intentional? I'm currently using gojq instead of jq specifically because of how it handles values like this, and the lossless approach seems like it would generally be the least likely to cause issues for users.
The text was updated successfully, but these errors were encountered: