-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
json float parsing problem #98
Comments
This is correct. The parser will store number values as integers where possible. |
Ah alright. |
(As a background: The parser needs to decide how to store a read number. Without knowing whether it is a floating-point or integer number, I chose the following strategy:
If (3) does not yield precision loss, value (2) is used (integer). Otherwise, value (1) is used (floating-point).) |
Hi Niels, stupid question, but why not make the decision based on the presence of a floating point separator (aka a dot). In my understanding, the parser will have a character representation of the number at some point, or may conditionally branch when encountering a dot inside a number. i.e.
Thanks and cheers, |
+1 for that. |
It's not that simple: "10E-3" = 0.01 (not containing a dot, but negative exponent) I understand your idea, but since JSON does not specify a format for numbers, a JSON library cannot guarantee that it stores numbers in the "correct" format - it can only make sure that it stores them without loosing too much precision. Therefore, I try to use the integer type ( |
The above code complies without problem, but the output is:
this is int
this is not a number
The text was updated successfully, but these errors were encountered: