# number_format() Support rounding negative places

- Thread: https://externals.io/message/120668
- Original archive: https://news-web.php.net/php.internals/120668
- Started by Marc Bennewitz on 2023-06-23T07:53:34+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #120668 — Marc Bennewitz — 2023-06-23T07:53:34+00:00

URL: https://externals.io/message/120668#120668

Hi internals,

I have opened a very small PR at https://github.com/php/php-src/pull/11487

I was told to send an email here and ask for feedback.

This PR adds support for rounding negative |$decimals| in |number_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 of |round()|.

The previous behavior wasn't documented or tested at all.


if there are no objections, Ilija has agreed to merge this for master. 
We will of course document this accordingly.


Thanks,

Marc
