Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120376 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 215 invoked from network); 21 May 2023 15:21:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 May 2023 15:21:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3609180083 for ; Sun, 21 May 2023 08:21:24 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 21 May 2023 08:21:24 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 327CF32008C0 for ; Sun, 21 May 2023 11:21:23 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Sun, 21 May 2023 11:21:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1684682481; x= 1684768881; bh=zyfuZ9TfUOkTbcGhQdQNQScpv74VYZ8VDQIbZXjYT+A=; b=n H66+0KHufgdC8mazjnMv2tAkS53cxF02UHA07F+RHUuXPQD0RQ5yHyKv3gm9lp23 AM0pQS4u6W2nvtYwa1GJ2p4t3jZYAi3qqfsrxW5S7MusTI/uMWLEW3EgMbJjcoce WONBfIANdN4P3JjQHW2cdaPV+VdiAQRfsdQK6p3Yg0/S6Hv11EXCy7MS6rcKxBuH IHSlHUlVW3VMNfM9NZ4unZA3lRLQ2MnLgjn/jOO5MI61qErfpgSVA+c1qLbMflJ1 c93QV/YkOPoz+u3X0N+TMxUKn2RRlScGkGzKBgcWVrfLRFptAcqrTOqmvttLXc9n E858nUvWIt6u3LHqE4biw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1684682481; x=1684768881; bh=zyfuZ9TfUOkTb cGhQdQNQScpv74VYZ8VDQIbZXjYT+A=; b=Ra1tjU1xoQfWXzCLyOyihJ7joBOaX jrTsPyUNHA3j4HGvOnrpmLAjzaHmAXz1hO3uDYzw3a2mjP+KqFQO/+ZXSsbO5Z8p YHfV5JeIOLeamPjMImwACK2vW4olh0YSf5WiO2bTw0YeSm12PuN3jqNEU63Sn7ZD 4MprhFaTWrThai/xpd/dQ6gqlPfO2ne9uAvpR17CfWlUXbV/RSvI89kkvaBXWhL4 7Qrc0dyRLqQlPx09mH/1ULynRi4mJ4w6jcqBDK/WmvCoTNqEdAj6B/4czvBC6RHS RMzDCeo/ejr9Ys9T2WPQyfnNYHduwUBKwp2cUaTeQxMCfjn6U+42t37bQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeiledgkeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 715DA1700089; Sun, 21 May 2023 11:21:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-431-g1d6a3ebb56-fm-20230511.001-g1d6a3ebb Mime-Version: 1.0 Message-ID: <8b23cbe6-1c4d-40b6-a68b-780d5e8f9dbf@app.fastmail.com> In-Reply-To: <4D8DE606-5E99-4D6F-962E-CBE1392C4B94@gmail.com> References: <05b7e019-27d4-e6a9-2088-f712c22317a9@mabe.berlin> <4D8DE606-5E99-4D6F-962E-CBE1392C4B94@gmail.com> Date: Sun, 21 May 2023 10:20:57 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] rounding integers From: larry@garfieldtech.com ("Larry Garfield") On Sun, May 21, 2023, at 7:18 AM, Rowan Tommins wrote: > On 21 May 2023 13:00:30 BST, Dan Ackroyd wrote: >>On Sun, 21 May 2023 at 06:16, Marc 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