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

Float comparison in 4.0.8 #104

Closed
donatj opened this issue Mar 2, 2023 · 1 comment
Closed

Float comparison in 4.0.8 #104

donatj opened this issue Mar 2, 2023 · 1 comment

Comments

@donatj
Copy link

donatj commented Mar 2, 2023

In 4.0.7 and prior checking the equality of 1/3 vs 1 - 2/3 came out as true, upgrading to 4.0.8 however it now declares

SebastianBergmann\Comparator\ComparisonFailure : Failed asserting that 0.33333333333333337 matches expected 0.3333333333333333

$comparatorFactory = ComparatorFactory::getInstance();
$comparator = $comparatorFactory->getComparatorFor(1/3, 1 - (2/3));

$comparator->assertEquals(1/3, 1 - (2/3));

I could see this being an intentional change as it's arguably "more correct" but seems like a pretty major change for a 3rd point release.

@sebastianbergmann
Copy link
Owner

This was discussed in sebastianbergmann/phpunit#4967, #99, and #102.

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

No branches or pull requests

2 participants