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

Fixed reported by PHPStan v0.12.99 #347

Merged
merged 1 commit into from
Oct 7, 2021

Conversation

StudioMaX
Copy link
Collaborator

No description provided.

}
$floatvalue = ($signbit ? 0 : -0);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, there was a warning that this line replaces the result from the previous condition.
But if you look in more detail, this line was always incorrect (even when compared with the previous condition).
According to IEEE 754:

If E=0 and F is zero and S is 1, then V=-0
If E=0 and F is zero and S is 0, then V=0

In practice, there is no difference, since (int) 0 === (int) -0.
Starting from PHP 7.0, floating zero can be negative, but this still does not matter, since (float) 0.0 === (float) -0.0.
Example: https://3v4l.org/jo7Nv

@JamesHeinrich JamesHeinrich merged commit a440175 into JamesHeinrich:master Oct 7, 2021
@StudioMaX StudioMaX deleted the update-phpstan branch October 7, 2021 12:12
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