-
Notifications
You must be signed in to change notification settings - Fork 7.9k
NAN in array compare #18563
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
Comments
This is IEEE-754 behavior, so it's not something we can or should change. Hence, I would classify this as a wontfix. But I'll give some time for others to chime in. |
I have updated the description to stress the current issue and discuss the fix better. |
I would agree. |
I probably agree the cost of fixing this is probably too high if |
Uh oh!
There was an error while loading. Please reload this page.
Description
The following code:
Resulted in this output:
But I expected this output instead:
online repro: https://3v4l.org/CVGBt
I understand the reason - in the 1st case, the zval reference is the same, thus used for the comparison, which is valid for all values excl. NAN. In the 2nd case, zval references are not the same, thus all array items are compared and because currently NAN === NAN returns false, the result is false.
Proposed fix: NANs should be counted in zval and the 1st case can then return the right result correctly and fast as well.
Alternatively, NAN, at least in arrays, can be considered to be true for weak and strict equality. This is my favorite but it might violate IEEE-754, but we already compare null === null...
PHP Version
any
The text was updated successfully, but these errors were encountered: