Re: rounding integers
| From: | Rowan Tommins | Date: | Sun, 21 May 2023 12:18:28 +0000 |
| Subject: | Re: rounding integers | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120375@lists.php.net to get a copy of this message | ||
On 21 May 2023 13:00:30 BST, Dan Ackroyd <Danack@basereality.com> wrote:
>On Sun, 21 May 2023 at 06:16, Marc <marc@mabe.berlin> wrote:
>>
>> Do you think this could be an acceptable BC-break
>
>No. Suggesting changing a 30 year old maths operations is a huge BC break.
>
>> or should this be a different function?
>
>Just make your own that does precisely what you want...
I agree on the first point, but disagree on the second. It's far too late to change round()
itself, but the lack of built-in functions for converting to int in a controlled way is frustrating,
particularly as the fashion moves towards stronger typing in general.
On the surface, it sounds like a trivial operation, but there's a lot of edge cases to think
about (limits of FP precision, negatives including negative zero, etc), and shipping a robust
implementation of int_round, int_floor and int_ceil in core would save everyone having to rediscover
them the hard way.
Regards,
--
Rowan Tommins
[IMSoP]