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

Drop wrong float comparison using PHP_FLOAT_EPSILON #2656

Open
wants to merge 1 commit into
base: 1.10.x
Choose a base branch
from

Conversation

mvorisek
Copy link
Contributor

discussion #2358 (comment)

PHP_FLOAT_EPSILON is small but still much larger than "small floating point values" - https://3v4l.org/570q1

abs($this->value - $type->value) < PHP_FLOAT_EPSILON condition for small numbers always wrongly returned true, === is the only valid cmp as long as both left/right side of the operator are of type float

@mvorisek mvorisek changed the title Drop wrong comparison using PHP_FLOAT_EPSILON Drop wrong float comparison using PHP_FLOAT_EPSILON Sep 30, 2023
@mvorisek mvorisek marked this pull request as ready for review September 30, 2023 12:45
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@mvorisek
Copy link
Contributor Author

the failing tests are unrelated

@ondrejmirtes
Copy link
Member

These changes need tests to see what they’re sctually fixing.

@mvorisek
Copy link
Contributor Author

help welcomed with tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants