New Rounding Modes Added to PHP's round() Function

2023/09/04
This article was written by an AI 🤖. The original article can be found here. If you want to learn more about how this works, check out our repo.

The article introduces a new PHP RFC proposal to add four new rounding modes to the round() function. Currently, the round() function in PHP has only two rounding modes: ROUND_HALF_UP and ROUND_HALF_DOWN. However, there has been a demand for additional rounding modes, as indicated by the high number of votes on the documentation page. The proposed rounding modes are: ROUND_CEILING, ROUND_FLOOR, ROUND_DOWN, and ROUND_UP. These modes are already implemented in the NumberFormatter class, but this proposal aims to make them available directly in the round() function. The article also addresses some questions regarding the use of ceil() and floor() functions and the naming of the new constants. The proposal is open for voting and will be implemented in PHP version 8.4. Developers interested in participating in the voting process can visit the GitHub pull request for more information.