Re: [RFC] [discussion] Correctly name the rounding mode and make it an Enum
| From: | Tim Düsterhus | Date: | Sun, 16 Jun 2024 10:56:46 +0000 |
| Subject: | Re: [RFC] [discussion] Correctly name the rounding mode and make it an Enum | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123631@lists.php.net to get a copy of this message | ||
Hi
On 6/13/24 03:28, Gina P. Banyard wrote:
Thank you, I think other than possibly prefixing the NegativeInfinity and PositiveInfinity cases with "Towards" I am happy with the content of the RFC.I've discussed this with Saki. In that case the
HalfEven and HalfOdd modes would also need to be renamed to HalfTowardsEven and HalfTowardsOdd, resulting in this:
enum RoundingMode
{
case HalfAwayFromZero; // PHP_ROUND_HALF_UP
case HalfTowardsZero; // PHP_ROUND_HALF_DOWN
case HalfTowardsEven; // PHP_ROUND_HALF_EVEN
case HalfTowardsOdd; // PHP_ROUND_HALF_ODD
case TowardsZero; // PHP_ROUND_TOWARD_ZERO
case AwayFromZero; // PHP_ROUND_AWAY_FROM_ZERO
case TowardsNegativeInfinity; // PHP_ROUND_FLOOR
case TowardsPositiveInfinity; // PHP_ROUND_CEILING
}
Except for the AwayFromZero modes, every mode contains Towards and especially the HalfTowardsX modes are too similar to easily distinguish them visually.
Thus we prefer the current state of the RFC where the different modes have plenty of hamming distance, while still being sufficiently descriptive.
Best regards
Tim Düsterhus