Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122601 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 091431AD8F6 for ; Sun, 10 Mar 2024 15:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710084745; bh=jwKWlIficYpO9pMf0pjI65q7oGrTbK0CVJJDeNVO/Qw=; h=Date:To:From:Cc:Subject:In-Reply-To:References:From; b=j/NszagDwF4GnLSdsUBoavVulVGkXvUtOqXvZ7O+/sWW6WDxkbmC6EBqtXXs0A1Gk oJk8Cw5ZiROnf8YhLd0gPY3dQs2FPJdpPyW8x8qZlcwQwHTcc6hg5mmSIS4AOV/sbH B72V012hW1xtjmfx9b0JbgImcoIMNgR9A6nkW9iC5oc3LWFRXUWOh/3oLPxFogwmd1 o76lrsZWQN8ZRNZlXriBcj42fKHJub+Ule9MVkNSfMjTWE6PRRIMKI3p/XQm9JpSkE fryS4KRcSytX82IoNVx1bBDUTjZGesZfGIV0NZU+68Qh/FxMYCpIAxeo1ySzgBW6sq BAOi1bh+YMtMw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 02A14180068 for ; Sun, 10 Mar 2024 15:32:24 +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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) (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 ; Sun, 10 Mar 2024 15:32:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail; t=1710084725; x=1710343925; bh=jwKWlIficYpO9pMf0pjI65q7oGrTbK0CVJJDeNVO/Qw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Kui5j6Otp7X6Sgam17WaWXpHT0uoGb3Ycy3DRmXl7G4a1UeRoe+RxGNih4dGQ20Br aPMgrh2G1jebsuYx0E0/s2I/Gdq2X1J5sLWFjz9CZi6idXfJ0/Q1dhj8lTb3u6lcQi J/0JcApbUFh6t/25IRXfjnlG7FahHGeHPGp+9EtIPEAWxk8bv7MacplSiXZar16jcj t7kYajkvf8DZhc+ETJqKsqLkddfrgMFkUdhyH1bikSeF/Io9b4fLZt0p2N5lIF/gT6 BnotugsFj4gUanpafjHXfT50l/fZWmWSiG5uyDVEMuQSfnchEb4Xdc3qQE5D4fwUU6 62A3QasDecwig== Date: Sun, 10 Mar 2024 15:31:51 +0000 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] [RFC] [Discussion] Rounding Integers as int Message-ID: In-Reply-To: <73b032ec-b41a-4b96-8254-f0b68abf87f2@app.fastmail.com> References: <07407c20-09ea-4bb9-a5cf-3af41b9234ee@mabe.berlin> <8a96a374-eaf8-4ac6-b45c-61d2a0c9652f@mabe.berlin> <73b032ec-b41a-4b96-8254-f0b68abf87f2@app.fastmail.com> Feedback-ID: 96993444:user:proton Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") On Saturday, 9 March 2024 at 16:00, Larry Garfield = wrote: > I am still opposed to this. Logically, ceil/float/round should be returni= ng ints, not floats. Only returning ints if it was given an int is, er, kin= da pointless, as you'll just get back the value you passed in. (Because it'= s already rounded/floored, etc.) So this doesn't get us any new type safety= , but does make the return type less consistent than it is today. That's a = step backwards. >=20 > If there's some math reason that we cannot have those functions return in= t (someone mentioned there was, but I don't really understand it and the RF= C does not explain it at all), then we should at least keep consistency in = the return type. "Sometimes I have to cast the return value before I can ac= tually use it in the obvious way, sometimes I don't" is not a good situatio= n. >=20 > --Larry Garfield There are plenty of values that are exactly representable as floating point= numbers but not as integers. One short example: $v =3D 1e10 + 0.6; var_dump($v); var_dump(round($v)); Gives you accurate precision and proper rounding behaviour. 1e10 *cannot* be represented as an integer. So round *must* be able to return a float. Best regards, Gina P. Banyard