rfc:new_rounding_modes_to_round_function
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:new_rounding_modes_to_round_function [2023/08/30 23:10] – created jorg_sowa | rfc:new_rounding_modes_to_round_function [2023/12/21 15:21] (current) – Changed status to implemented jorg_sowa | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Target version: PHP 8.4 | * Target version: PHP 8.4 | ||
* Author: Jorg Sowa < | * Author: Jorg Sowa < | ||
- | * Status: | + | * Status: |
* Implementation: | * Implementation: | ||
* First Published at: http:// | * First Published at: http:// | ||
Line 11: | Line 11: | ||
The RFC proposes to add 4 new modes to the round() function. | The RFC proposes to add 4 new modes to the round() function. | ||
- | - [[https:// | + | * [[https:// |
- | - [[https:// | + | |
- | - [[https:// | + | |
- | - [[https:// | + | |
- | Two first comments on the documentation page of the round() function are related to the missing modes of rounding. The first comment has a outstanding 309 votes. | + | Two first comments on the [[https:// |
Moreover, the [[https:// | Moreover, the [[https:// | ||
Line 24: | Line 24: | ||
Adding 4 new constants for the rounding modes of function round(): | Adding 4 new constants for the rounding modes of function round(): | ||
- | - PHP_ROUND_CEILING - rounds num to the nearest integer bigger than num, | + | * PHP_ROUND_CEILING - rounds num to the nearest integer bigger than num, |
- | - PHP_ROUND_FLOOR - rounds num to the nearest integer lower than num, | + | |
- | - PHP_ROUND_AWAY_FROM_ZERO - rounds num away from zero, | + | |
- | - PHP_ROUND_TOWARD_ZERO - rounds num towards zero. | + | |
+ | |||
+ | Creating two aliases of constants from Intl extension to have consistent naming for rounding modes: | ||
+ | |||
+ | * ROUND_TOWARD_ZERO (equivalent of PHP_ROUND_TOWARD_ZERO) alias of [[https:// | ||
+ | * ROUND_AWAY_FROM_ZERO (equivalent of PHP_ROUND_AWAY_FROM_ZERO) alias of [[https:// | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 34: | Line 39: | ||
===== Proposed PHP Versions ===== | ===== Proposed PHP Versions ===== | ||
+ | |||
8.4 | 8.4 | ||
Line 39: | Line 45: | ||
==== Why not use functions ceil() and floor()? ==== | ==== Why not use functions ceil() and floor()? ==== | ||
- | The functions ceil() and floor() round numbers to the full integer, while the function round() | + | The functions ceil() and floor() round numbers to the full integer, while the function round() |
+ | < | ||
+ | ceil($number) === round($number, | ||
+ | floor($number) === round($number, | ||
+ | </ | ||
- | ==== Why not the names PHP_ROUND_UP and PHP_ROUND_DOWN ==== | + | ==== Why not the names PHP_ROUND_UP and PHP_ROUND_DOWN? ==== |
- | Such constants already exist in the NumberFormatter and represent rounding modes 'away from zero' and ' | + | Such constants already exist in the [[https:// |
+ | |||
+ | Those constants would be deprecated and replaced with their corresponding aliases: ROUND_TOWARD_ZERO and ROUND_AWAY_FROM_ZERO. | ||
+ | |||
+ | ==== Why not the enum implementation for the rounding modes? ==== | ||
+ | As this is extension of the existing modes we should add complementary modes to the existing constants instead implementing new Enum. This way enum is an addition to the new constants | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
Line 48: | Line 63: | ||
As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | As per the voting RFC a yes/no vote with a 2/3 majority is needed for this proposal to be accepted. | ||
- | Voting started on 2023-09-x and will end on 2023-09-x. | + | Voting started on 2023-11-15 and will end on 2023-11-30 00:00 GMT. |
- | <doodle title=" | + | |
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | If the first voting is not accepted the result of the second voting will be ignored. | ||
+ | |||
+ | <doodle title=" | ||
* Yes | * Yes | ||
* No | * No | ||
Line 62: | Line 87: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
Keep this updated with features that were discussed on the mail lists. | Keep this updated with features that were discussed on the mail lists. | ||
+ |
rfc/new_rounding_modes_to_round_function.1693437057.txt.gz · Last modified: 2023/08/30 23:10 by jorg_sowa