On Friday, 12 July 2024 at 12:24, Christoph M. Becker <[email protected]> wrote:
> Hi all,
>
> there has been a "small" change in the rounding logic of
> _php_math_round()[1] a couple of months ago. A respective ticket,
> claiming the new behavior would be a bug[2] had been filed a while ago
> without proper triage so far. I'm bringing this to your attention,
> because I'm afraid that there will be (many) more bug reports about this
> in the future (note that the change only affects master, and only PHP
> 8.4.0alpha1 has been released yet, so it is probably not widespreadly
> tested yet). At the very least we should be sure that we want to keep
> this change, and document it well, to avoid discussions in every filed
> ticket.
>
> My personal stance on this is simple: floating point arithmetic is not
> exact per se, and changes to how PHP handles the details should only be
> introduced, if they clearly improve things. This change apparently
> improves some cases, but worsens others. Thus, I think the change
> should better be reverted, and if at all, postponed to PHP 9, since I
> neither regard this change as bug fix nor as a feature.
>
> What do you think?
>
> [1] https://github.com/php/php-src/pull/12222
>
> [2] https://github.com/php/php-src/issues/14332
I agree, this situation is extremely suboptimal.
My understanding as to why people declined the "Change the edge case of round()" RFC [1]
was because they were worried about the silent change in behaviour.
However, most people seem to have missed the fact, myself included, that regardless of it being
accepted or not there would have been changes to the behaviour.
As such we have the worst of both worlds, continuing to have incorrect floating point semantics for
people that rely on proper IEEE 754 floating points,
and yet we still have a silent change in behaviour due to the partial bugfix.
Moreover, these fixes made the implementation of round() more complicated, for marginal benefits
IMHO.
Best regards,
Gina P. Banyard
[1] https://wiki.php.net/rfc/change_the_edge_case_of_round