Re: [RFC] [Discussion] Add 4 new rounding modes to round() function
| From: | Alexandru Pătrănescu | Date: | Fri, 08 Sep 2023 15:10:29 +0000 |
| Subject: | Re: [RFC] [Discussion] Add 4 new rounding modes to round() function | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-121017@lists.php.net to get a copy of this message | ||
On Thu, Sep 7, 2023 at 11:10 PM Jordan LeDoux <jordan.ledoux@gmail.com>
wrote:
>
> As someone who maintains a math library in PHP that has its own expanded
> rounding implementation, I will politely disagree. Away from zero, towards
> zero, towards positive infinity, and towards negative infinity are
> completely and utterly unambiguous and provide the developer with precise
> control over what behavior they want. I don't see a reason to use something
> that we KNOW is ambiguous when we're designing it.
>
>
I agree. My main point was consistency.
On Tue, Sep 5, 2023 at 1:34 AM Jorg Sowa <jorg.sowa@gmail.com> wrote:
> Thank you all for the comments. The naming brought some constructive
> discussion.
>
> My preferred solution would be inconsistent PHP_ROUND_AWAY_FROM_ZERO and
> PHP_ROUND_TOWARD_ZERO as those are friendlier to the most of developers and
> are not possible to mistake with other modes. I would go even one step
> further and create aliases for NumberFormatter constants to have the naming
> consistent.
>
>
Yes, this is a great way to achieve consistency, adding aliases also in
NumberFormatter.
Thank you,
Alex