[php-src] PR #11741: Introduce two new modes to round function
| From: | jorgsowa | Date: | Tue, 18 Jul 2023 21:24:23 +0000 |
| Subject: | [php-src] PR #11741: Introduce two new modes to round function | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-23105@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11741
Author: jorgsowa
This PR introduces two new modes to the
round() function:
[PHP_ROUND_UP](https://en.wikipedia.org/wiki/Rounding#Rounding_up) and
[PHP_ROUND_DOWN](https://en.wikipedia.org/wiki/Rounding#Rounding_down).
Those two modes are frequently used in accounting and are heavily requested by the PHP users. Two
first comments in [round() documentation
page](https://www.php.net/manual/en/function.round.php) is about this feature and how can it now be
achieved in the userland. However if we already have 4 existing modes it's not big effort to
implement next two modes which are more popular than existing PHP_ROUND_HALF_EVEN and
PHP_ROUND_HALF_ODD.
Results for the default mode (PHP_ROUND_HALF_UP) for the function round() are a little
bit slower than current version. I am not sure how can I speed it up, because by the code, it costs
the same amount of time.