On Sun, May 21, 2023, at 7:18 AM, Rowan Tommins wrote: > On 21 May 2023 13:00:30 BST, Dan Ackroyd <dan...@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.
Having recently been bitten by floor() returning a float even though the value that comes back is logically an int, I would be fully in support of "and returns an int" versions of these functions in core. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php