Skip to content

Conversation

TimWolla
Copy link
Member

Positive and negative zero normally compare equal, but when specifically retrieving a minimum or maximum from a list of numbers, we should consider -0.0 to be lower than 0.0 instead of treating them the same and returning the “first match”.

Fixes #20221


Targeting PHP 8.5, since I consider this a bugfix, but not important enough for the fully-released branches.

Positive and negative zero normally compare equal, but when specifically
retrieving a minimum or maximum from a list of numbers, we should consider
`-0.0` to be lower than `0.0` instead of treating them the same and returning
the “first match”.

Fixes php#20221
@@ -0,0 +1,90 @@
--TEST--
GH-20221: max/min return wrong value if signed (negative) zero
Copy link
Contributor

Choose a reason for hiding this comment

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

does also apply for sort - https://3v4l.org/9UMvV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants