Skip to content

Introduce two new modes to round function#3

Closed
jorgsowa wants to merge 20 commits intomasterfrom
add_modes_up_and_down_to_round_function
Closed

Introduce two new modes to round function#3
jorgsowa wants to merge 20 commits intomasterfrom
add_modes_up_and_down_to_round_function

Conversation

@jorgsowa
Copy link
Owner

@jorgsowa jorgsowa commented Jul 13, 2023

This PR introduces fours new modes to the round() function: PHP_ROUND_UP, PHP_ROUND_DOWN, PHP_AWAY_FROM_ZERO and PHP_TOWARD_ZERO.

Those four modes are frequently used in accounting and are heavily requested by the PHP users. Two first comments in round() documentation page is about this feature and how can it currently be achieved in the userland. However if we already have 4 existing modes it's not big effort to implement next four modes which are more popular than existing PHP_ROUND_HALF_EVEN and PHP_ROUND_HALF_ODD and in fact completing all of the most popular rounding modes.

Performance for the default mode (PHP_ROUND_HALF_UP) for the function round() in my version is a little bit slower than in current version. I am not sure how can I speed it up, because by the code, it costs the same amount of time.

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.

1 participant