Skip to content

ext/bcmath - Fixed GH-17049: Correctly compare 0 and -0 - #17051

Closed
SakiTakamachi wants to merge 4 commits into
php:PHP-8.4from
SakiTakamachi:fix/gh17049
Closed

SakiTakamachi wants to merge 4 commits into
php:PHP-8.4from
SakiTakamachi:fix/gh17049

Conversation

@SakiTakamachi

Copy link
Copy Markdown
Member

fixes #17049

Comment thread NEWS Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

8.4.2 is tagged already, I guess this branch is outdated.

Comment thread ext/bcmath/libbcmath/src/compare.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand the change in bc_str2num.
However, I don't fully understand this change: why is this necessary on 8.4 but not on lower branches?

@SakiTakamachi SakiTakamachi Dec 5, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is for Number objects, so it is not necessary for lower branches.

(scale and n->n_scale differ only in Number objects. This happens when explicitly specify the scale in a Number method.)

Perhaps it would be more efficient to compare the scale first in the order of the if conditions?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this maters a lot for performance.
I missed that the scales are not the same for Number objects of course. Please add a small comment to the check to explain this.

@SakiTakamachi

Copy link
Copy Markdown
Member Author

Fixed!

@SakiTakamachi SakiTakamachi changed the title ext/bcmath - Correctly compare 0 and -0 ext/bcmath - Fixed GH-17049: Correctly compare 0 and -0 Dec 6, 2024

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See my comment, otherwise LGTM

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks

@SakiTakamachi

Copy link
Copy Markdown
Member Author

The last force push just resolved the NEWS conflict. I'll merge, thanks for the review!

SakiTakamachi added a commit that referenced this pull request Dec 6, 2024
* PHP-8.4:
  Correctly compare 0 and -0 (#17051)
@SakiTakamachi
SakiTakamachi deleted the fix/gh17049 branch December 6, 2024 16:53
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