Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:124412 php.internals:124413 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id E01D91A00B7 for ; Fri, 12 Jul 2024 15:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720798063; bh=9b3vgQZaBMxJusSpnudwbdLCngOH6cdQ3XQqYVs0Otk=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=E82Xq8psXX2Z0Y4KihxeCj78bbOlA/6aW4db0udfd4XIcnVh3YF9Xirc1l8dJ3bpH /yQ2AfIWvagxbEF8O9jxrD63kugkboS+URp8G9NS8tHgJGsuGlR4WpHpmHPD3yiH62 FB+GWTZoqbzkq7A1qaS3hvkonf8HY2Vle6roOa9+dkRk+4jyXU/VF1hh7DGBHYcdvs go8sVbENsT0GVj8jXQlGgNIk4oYjh6ouf8Er6QRI3TVkDTaCzMQHg/yf+vKF7NVQZh rdazjk5FD3znTM17QtGUwrD8C/QqLm6FjC14/Ds2N6qOufotaXXsaysIen/AOnuidc oL8Dko3p4rqzg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1E5A2180030 for ; Fri, 12 Jul 2024 15:27:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 12 Jul 2024 15:27:42 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5957040e32aso1342091a12.2 for ; Fri, 12 Jul 2024 08:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720797974; x=1721402774; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gJw5cwQ26d9qBv6v7WOiX/HUDpRiM7GKMweBebtlpdQ=; b=KHWmMwP5qxRpsZtE3M4eNnAhr4jGzdSfBfP7nN9vmGTQaKG7v0JxOSitRQG2vpEBlu lcGRR8IREpmAfl+TIpRHHhfrkssHz/9zeaYXjCiNscuncbHNNvWATTamO+T+tXIHoggP 3XeqIvIHSxKn6RPE/jow5/ulrGnyyTj3JpY/5RBP+c7/f/Afkgmek2gUSDZO6/f8ihAI EV1mz4YgixOwcYmx8OVTK1EkgeTb9WJbaX43DyhZGF9z9sUiDt5zLo6TxE0XR2OJVd+9 Srjvbnooe/c13zdJL98eS5UqzrXb+mZxQ7nkWM15Z8SMRnOMp48uz8dIWj5u1XM6+aO5 GWew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720797974; x=1721402774; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gJw5cwQ26d9qBv6v7WOiX/HUDpRiM7GKMweBebtlpdQ=; b=Xrgslyc0XQ0Pz7ITDBaIaHj7tyLQpsbll+YQCWdgtKpQrmXD0/X4QL2mWzcRiBeqxR grqR/iAqDy56IJxkJkjKODBIBLWGYDoDylB/KNMt7q9E+mgwNQBvu8QNFAOEKSvbGamq cnHL1CwKwAaRcqRuhMjZbz4H0t1TgJTrcRRq8ZntyqGSzSBFVa94hNIUNtUI+RRzq4vk azwC51xwH4uOnD8hAkEB5CXbSCsbFK5LYc7wAsp5vQ/qu2zLvONfdYDv+V6w88MEy7TE 88nLyC6BMJEIPkeo5di4gGYZJrgSPORUSExPr1h/rgMLNM5OtsFjAXconbp26C+BW2vI vmaA== X-Gm-Message-State: AOJu0YxV+wDE7HOHdDz8hUq4MPkvJegqsYOA1OiSnc+uwx/+rsiThZN3 nHAGuPexNMiQVwPpEimgp1jMyEqo8COaJrF9sBkYYbZ8vny3CQ8r X-Google-Smtp-Source: AGHT+IFBVI+AVjIf+b8WUhl5DSx3Q7BrrBjRX3K9nNOoltZSUGBAH5cNFRRs1wgYt/xLMMloAbdomg== X-Received: by 2002:a05:6402:27ce:b0:58f:41e0:8d22 with SMTP id 4fb4d7f45d1cf-594bab8083fmr13809187a12.1.1720797973969; Fri, 12 Jul 2024 08:26:13 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a7ff00bsm353535666b.118.2024.07.12.08.26.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jul 2024 08:26:13 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] Breaking change of rounding behavior in PHP 8.4 In-Reply-To: Date: Fri, 12 Jul 2024 17:26:02 +0200 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <8918688A-2EE4-443F-8FAC-DBF9957AAD51@gmail.com> References: To: "Christoph M. Becker" X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) > Le 12 juil. 2024 =C3=A0 13:24, Christoph M. Becker = a =C3=A9crit : >=20 > Hi all, >=20 > 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. >=20 > 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. >=20 > What do you think? >=20 > [1] > [2] >=20 > Cheers, > Christoph Hi, See [1] and [2], which motivated the change.=20 I expect that `round($anything) =3D=3D (int) round($anything)` for any = float between PHP_INT_MIN and PHP_INT_MAX, and I think that the change = fixed that . Therefore, I am for keeping the change, and ensuring that there are test = cases for 4503599627370495.5 (the largest float with fractional part). =E2=80=94Claude [1]: https://github.com/php/php-src/issues/12143#issuecomment-1713465981 [2]: https://3v4l.org/3Q7BC