Re: Incorrect terminology usage for rounding modes of round()

From: Date: Sun, 14 Apr 2024 18:25:03 +0000
Subject: Re: Incorrect terminology usage for rounding modes of round()
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-123133@lists.php.net to get a copy of this message
On Sun, Apr 14, 2024, at 11:49 AM, Tim Düsterhus wrote: > Hi > > On 4/14/24 16:33, Gina P. Banyard wrote: >> Considering that PHP 8.4 is also adding new rounding modes via the "Add 4 new rounding >> modes to round() function" RFC [4] attempting to solve this issue in this next version of PHP >> seems like a good idea. >> In my discussions with Saki about this issue, it seems that her and Tim have thought about >> creating a new enum for rounding modes, looking something like this: >> >> enum RoundingMode { >> case HalfAwayFromZero; >> case HalfTowardsZero; >> case HalfEven; >> case HalfOdd; >> case TowardsZero; >> case AwayFromZero; >> case NegativeInfinity; // or case Floor; >> case PositiveInfinity; // or case Ceiling; >> } > For PHP 8.4, I'd first make it int|RoundingMode to keep > the constant > values the same (in case the constants are re-used by a userland > library). Narrowing it down to just RoundingMode and updating the > constants can happen in a later version. I support this change. While I don't know who would be using the rounding mode constants for other purposes, I'm not opposed to taking a more gradual approach if that's the consensus. At least a version would allow people time to realize, oops, I should not use someone else's constants.. :-) I also don't have a strong opinion between making it global vs a Math namespace. (But as Derick notes, not Maths, for consistency.) --Larry Garfield

« previous php.internals (#123133) next »