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

Use predefined INF/NAN constants instead of float/string #325

Merged
merged 1 commit into from
May 28, 2021

Conversation

StudioMaX
Copy link
Collaborator

We have an incomprehensible state when, when calculating in BigEndian2Float and a string of INF/NAN was passed as a value. In that case we returned (bool) false for NAN values and (string) '+infinity'/(string) '-infinity' for infinity. And at the end of the execution of this method these values were cased to float.
In some PHP versions, the expression (float) '-infinity' even worked! See https://3v4l.org/14nSQ
But this was recognized as a bug and was fixed by this commit.

Therefore, just use the predefined constants INF and NAN, which are still float, but when converted to a string, they will be output as (string) 'INF' or (string) 'NAN'. And also we can use is_nan()/is_infinite() on these values.

@JamesHeinrich JamesHeinrich merged commit d662cbc into JamesHeinrich:master May 28, 2021
@StudioMaX StudioMaX deleted the float-inf-nan branch May 28, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants