Re: [RFC] [Discussion] Rounding Integers as int

From: Date: Fri, 06 Oct 2023 14:18:27 +0000
Subject: Re: [RFC] [Discussion] Rounding Integers as int
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-121250@lists.php.net to get a copy of this message
Hi Tim, On 05.10.23 21:57, Tim Düsterhus wrote:
Hi On 10/4/23 08:35, Marc Bennewitz wrote:
As far as I understand you are in favor of option 1. (considering it a bugfix) but how do you make sure this will not lead to different application behavior overlooked on upgrading? Also there is no way to opt-in new behavior.
Yes, I would be in favor of option 1 and I don't even see a reason not to do this in PHP 8.4 right away. As I mentioned before, this effectively can be considered a bug fix: PHP does not correctly round integers > 2^53. While this is not a bug fix that is appropriate for the current stable branches, I don't see why it would not be appropriate for PHP 8.4 if there's an RFC for it. In fact there is already a rounding bugfix (no RFC for that) in PHP 8.4: https://github.com/php/php-src/blob/65a8c70f93ccb7e008de147cd4c357681c653bd0/UPGRADING#L75-L82 While PHP tries hard to keep backwards compatibility within a given major, keeping full compatibility is effectively impossible for the huge API surface PHP exposes. Every version includes *some* changes that are technically breaking for one reason or another.
Fixing edge cases like having 0.49999999999999994 rounded down correctly is a different story than having something simple like "round(10 / 2) === 5.0" to return false instead.
Best regards Tim Düsterhus Best,
Marc

Attachment: [application/pgp-keys] OpenPGP public key OpenPGP_0x3936ABF753BC88CE.asc
Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc
« previous php.internals (#121250) next »