-
-
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
Comparison of NaN #514
Comments
In C++, |
OSS-Fuzz discovered this behavior, and I was not aware of it before. I just wanted to discuss whether the library's behavior isn't surprising to anyone else. I don't want to necessarily change anything. |
I think it would be weird if |
+1 to gregmarr's comment. |
I think nothing must be changed here, only the documentation must be clear. |
NaN values never compare equal to themselves or to other NaN values.
JSON values can store double precision floating-point numbers, including NaN. This is a problem when we compare two JSON values
j1
andj2
, becausej1 == j2
ultimately returnsj1.m_value.number_float == j2.m_value.number_float
. The latter returns false for NaN, so two JSON values which are bitwise equal are treated unequal because of this.Would it be a good idea to change the semantics of
==
in this regard to evaluatejson(NAN) == json(NAN)
to true? What do you think?The text was updated successfully, but these errors were encountered: