-
Notifications
You must be signed in to change notification settings - Fork 7.9k
number_format() Support rounding negative places #11487
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
Conversation
Hey @marc-mab Nice change! I am not sure what's the exact process of merging code, but shouldn't this improvement be documented in changelog somehow? It's for sure BC breaking change. |
Hi @jorgsowa, yes, it should be documented somehow but I'm not sure either about the process. Was hoping to get some reviews first and then what needs to be done for documenting it. About BC break I think this is extremely low and as the previous behavior wasn't documented or tested I would classify that into undefined behavior. I hope this little change doesn't need an RFC. |
It makes sense to match the behavior with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have an objection against this change. Just test needs improving.
0eea43e
to
907b554
Compare
@bukka Thanks for your review ... I have reverted the modified test file and added a new one testing multiple cases on the |
@bukka @iluuu1994 The two failing tests seems to be very much unrelated to this change. As I don't have the permissions to restart tests should I commit a dummy change or how is the way forward? |
@marc-mabe No worries, CI doesn't need to be green if it's obviously unrelated.
There hasn't been any feedback so I think we can merge this change for PHP 8.3. I'll do so in the coming days. |
I meged it so #11584 can get rebased and reviewed in time. |
This PR adds support for rounding negative
$decimals
innumber_format()
.Previously negative
$decimals
got silently ignored and the number got rounded to zero decimal places.With this change, when
$decimals
is negative,$num
is rounded to$decimals
significant digits before the decimal point.This is matching the behavior for the
$precision
argument ofround()
.The previous behavior wasn't documented or tested at all.