On Friday, 31 May 2024 at 18:15, Larry Garfield <[email protected]> wrote:
> On Fri, May 31, 2024, at 4:41 PM, Jorg Sowa wrote:
>
> > Hey Saki,
> > I like this change. When I was implementing additional rounding modes
> > for the next PHP version I was initially struggling with the naming and
> > this change will be helpful.
> >
> > I have only one concern about the names NegativeInfinity
and
> > PositiveInfinity
. They may be too formal from the user's perspective.
> > As we already have functions ceil
and floor
it's more
> > intuitive for
> > developers to understand the logic of ceiling and floor rounding.
> >
> > But if voters will prefer those terms then it makes sense to change the
> > constants implemented in PHP 8.4 (and thus not released yet) from
> > PHP_ROUND_(CEILING|FLOOR)
to
> > PHP_ROUND_(POSITIVE_INFINITY|NEGATIVE_INFINITY)
for the sake of
> > consistency.
> >
> > Kind regards,
> > Jorg
>
>
> I was confused by those as well. It's not obvious to me what those even do. Do they mean
> "away from 0"? If not, then I have no clue what they are. :-)
>
> --Larry Garfield
Considering that there are already "Away from 0" and "Towards 0" enum cases, the
Towards Positive Infinity/Towards Negative Infinity cases "obviously" don't mean
this.
Towards positive infinity means that for positive numbers you round to the integer part plus 1, and
for negative numbers you "just" take the negative integer part.
Similarly, for rounding towards negative infinity positive numbers round to "just" the
integer part of it, and negative numbers round to the negative integer part minus 1.
It should also be noted that ceil/floor is very English specific terminology that may not be
immediately obvious to non-English speakers, thus my preference for using some variation of towards
positive/negative infinity.
Best regards,
Gina P. Banyard