Use predefined INF/NAN constants instead of float/string #325
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have an incomprehensible state when, when calculating in
BigEndian2Float
and a string ofINF
/NAN
was passed as a value. In that case we returned(bool) false
forNAN
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/14nSQBut this was recognized as a bug and was fixed by this commit.
Therefore, just use the predefined constants
INF
andNAN
, which are still float, but when converted to a string, they will be output as(string) 'INF'
or(string) 'NAN'
. And also we can useis_nan()
/is_infinite()
on these values.