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

How to parse big decimal data #2036

Closed
YXQ212526 opened this issue Apr 13, 2020 · 3 comments
Closed

How to parse big decimal data #2036

YXQ212526 opened this issue Apr 13, 2020 · 3 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@YXQ212526
Copy link

Hi nlohmann,
I want to know how to parse data like this:
image
I use the parse () function to parse the original string and use ["data"] [0] ["amount"] to get the value,but I can't get accurate data, what I got is 7.953084699036454 instead of 7.953084699036454431
Looking forward to your reply, thanks!

@nlohmann
Copy link
Owner

The number 7.953084699036454431 cannot be expressed exactly by a 64 bit double, see https://float.exposed/0x401fcff56f72b7e2. The closest you can get is the number with hex representation 0x401fcff56f72b7e2. For this number, 7.953084699036454 is the shortest decimal representation. Therefore, this is used by the library.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Apr 13, 2020
@nlohmann
Copy link
Owner

Related issues: #1580 #1698

@YXQ212526
Copy link
Author

Thx for your reply 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants