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
Consider parsing -0 as a double and not as zero #1532
Comments
Python behaves like simdjson: >>> import math
>>> import json
>>> math.copysign(1, json.loads("-0"))
1.0
>>> math.copysign(1, json.loads("0"))
1.0
>>> math.copysign(1, -0.0)
-1.0
>>> math.copysign(1, json.loads("-0.0"))
-1.0 |
I am tempted to close this and leave "as is". The fix would be simple enough: is_float |= ((i == 0) && negative); But any user that really cares about -0 and wants portability would almost surely be careful enough to serialize it as "-0.0". Meanwhile, it is really subjective what |
The description indicates DOM already treats -0 as double, is that true? Is this about On Demand? In the On Demand API, you have to ask for either int or double, so I assume the issue is that |
@jkeiser The issue is that integer types in C++ have no notion of -0 but doubles do. So some people would consider We process In On Demand, we no longer distinguish between ints and doubles for the user. Still, if someone encountered
I think you would get |
Oh, so the idea is that if you ask for an integer, we treat -0 as INCORRECT_TYPE? |
@jkeiser Yes! But I am not sure I like this idea, but as you can see it is logical. |
Yeah. I feel sort of positive about the principle that we refuse to parse to a type if it loses information that would be preserved if we parsed to a different type. A compelling argument could be made that it is obvious which integer to assign this value, but we refuse to parse 1.1 to 1, and it seems like that would apply to integers as well. On the other hand, we refuse to parse 1.0 as an integer ... that doesn't fit the principle I suggested above. We don't preserve the number of decimal places when we parse doubles with trailing zeroes, so I don't think we can claim we're trying to preserve the number of significant digits ... |
Currently, we parse
-0
as0
(integer value) and-0.0
as (-0, double value) in the DOM API.The text was updated successfully, but these errors were encountered: