# Additional Rounding modes for the round() function

- Thread: https://externals.io/message/89948
- Original archive: https://news-web.php.net/php.internals/89948
- Started by Mark Baker on 2016-01-01T11:33:47+00:00
- Messages: 3
- 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

---

## #89948 — Mark Baker — 2016-01-01T11:33:47+00:00

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

I'd like to suggest a couple of additional options for the `round()` 
function, two new flags for PHP_ROUND_UP and PHP_ROUND_DOWN; which are 
similar to the existing `ceil()` and `floor()` functions, but allow a 
precision argument as well.

The PR is at https://github.com/php/php-src/pull/1658

-- 
Mark Baker

  _________
|.  \     \-3
|_J_/ PHP |
|| |  __  |
|| |m|  |m|

  I LOVE PHP

---

## #89995 — Andrea Faulds — 2016-01-04T17:12:01+00:00

URL: https://externals.io/message/89948#89995 · In reply to: #89948

Hi Mark,

Mark Baker wrote:
> I'd like to suggest a couple of additional options for the `round()`
> function, two new flags for PHP_ROUND_UP and PHP_ROUND_DOWN; which are
> similar to the existing `ceil()` and `floor()` functions, but allow a
> precision argument as well.
>
> The PR is at https://github.com/php/php-src/pull/1658
>

This seems like a sensible addition. That said, I'm not sure about those 
names, I think they might get confused with PHP_ROUND_HALF_UP/DOWN. 
Perhaps name them PHP_ROUND_CEIL and PHP_ROUND_FLOOR, or so? Or 
PHP_ROUND_ALWAYS_UP/DOWN?

Not sure if it matters.

Thanks!
-- 
Andrea Faulds
https://ajf.me/

---

## #90024 — Mark Baker — 2016-01-05T00:43:27+00:00

URL: https://externals.io/message/89948#90024 · In reply to: #89995

> Hi Mark,
>
> Mark Baker wrote:
> > […]
>
> This seems like a sensible addition. That said, I'm not sure about 
> those names, I think they might get confused with 
> PHP_ROUND_HALF_UP/DOWN. Perhaps name them PHP_ROUND_CEIL and 
> PHP_ROUND_FLOOR, or so? Or PHP_ROUND_ALWAYS_UP/DOWN?
>
Thanks for the feedback.

I see where you're coming from, though I'd chosen to use 
PHP_ROUND_UP/DOWN precisely because of the two existing constants 
PHP_ROUND_HALF_UP/DOWN to provide a degree of naming consistency. That 
being said, it's simple enough to change the names of new flag 
constants; but I'll wait a couple of days to see if anybody else weighs 
in with an opinion before updating the PR.

-- 
Mark Baker

  _________
|.  \     \-3
|_J_/ PHP |
|| |  __  |
|| |m|  |m|

  I LOVE PHP
