Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123082 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 E35511A009C for ; Wed, 10 Apr 2024 07:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712734674; bh=/OBmaG5Y59HMChpeeNS4EMWKvvWqaBHtHt3F3TVk+pk=; h=Date:From:To:Subject:In-Reply-To:References:From; b=VIp6p8yWolDwCE+vHlGX9VKP/hd1AJuxtwAGVQBAn1wrkLwMh7kuKXeUX13d66oGN 2R5LO7Tuf9h766J08K8r2WqaPPNVnemNNvkEGUUqhg9olLhboOWvWn8AH4eNlGOe4S Bh2hgAAJ4UR8znm6ejjUn+kEmUYtawNphCryWSZn1PPb/ETE+tkUjH8fGYyFvQ0QZA XYI7JLrJJfX5LV5H46nuhYryW/mDMjOtpG0/VxOl6ijeEFr3P2VVImgHs3dJJvOthS J4e8eJFuw4aOof2pQRoTBH9k5RRVyCmvC8JZqjhmFKemO1XNlilK0rPn8t7TB+oSi6 2bot/r50IFwxQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 07C671805E7 for ; Wed, 10 Apr 2024 07:37:52 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,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 wfhigh6-smtp.messagingengine.com (wfhigh6-smtp.messagingengine.com [64.147.123.157]) (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 ; Wed, 10 Apr 2024 07:37:51 +0000 (UTC) Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id C3C9F1800148 for ; Wed, 10 Apr 2024 03:37:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 10 Apr 2024 03:37:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1712734637; x=1712821037; bh=/OBmaG5Y59HMChpeeNS4EMWKvvWqaBHtHt3F3TVk+pk=; b= c2qGoyBgKKaBBdGMzZVHGJ+5p8rJ1E5T4q7MC8J1JPro+uleK9u1E3g4PCwHq7hI BrbCRibRGkelPR6nJngRhWoOT+YnacqfeQQSt2XBT0hkjbMZEuv7oxVrYbyASEzX dyIwBl+zj9TJR2lNGSd5SGBtQp/kx7PE41Mj2jV3SDxN8Fc1212kKgAnbKEXfAu9 9VH9hfa+XByqiFUbMx09g8YelOQqKX29L7otM/ja5ALSi9ecwVsYTVXvdun8S9z8 rtMnT5T1B4NYcO8oyLYe0igg/FKxLx+UnA+A8cJ9q5r3lmy7ABSKsX49SmaVoijj fqYPu94JpNmtCy0vSoqSRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712734637; x= 1712821037; bh=/OBmaG5Y59HMChpeeNS4EMWKvvWqaBHtHt3F3TVk+pk=; b=e Gjz+/ljbbbO7sKMXM6sStSjt5Y27sj7eo4y/3Cnu0Za5tFyAa0lkWBtQxj1AN+eg WYZG8N6u68ZXBJygjiz2cc/Nnd4dROyBDhcjGxPvOfjx4L/Dvq0OWG7XRa0kf1nr o7OXu1D5kjhI7Hg/EJB9nYLWdxgbzIp+Hirp64h9MXqVZTj3pS/dWiGJ6yd/fV/Y Q59utrNR6cYdTniQM0fRen6NOphbVDeiDfmtX1hWwXL6E4wz/Pu8BuzFnlN+nYNp LepmHS/Q6eopOVZpnCyQ2Q9kQL0dvyD4/BmNtx91miimNc5NkMd3tqNinF7U/A2Z olS7aYbhsnNrgl9rObwcg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehhedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffufggjfhfkgggtgfesth hqmhdttderjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgn fdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnh epheelffetiefgveduteefudegtdduveeludegueegleehiefhhefgtdekveevgfelnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhoph drphhhphesrhifvggtrdgtohdruhhk X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 10 Apr 2024 03:37:16 -0400 (EDT) Date: Wed, 10 Apr 2024 08:37:14 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath User-Agent: K-9 Mail for Android In-Reply-To: References: <6628b5e3-5f4b-4c9c-a940-56f72a645af1@rwec.co.uk> Message-ID: 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: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 10 April 2024 00:36:21 BST, Saki Takamachi wrote: >- The scale and rounding mode are not required for example in add, since = the scale of the result will never be infinite and we can automatically cal= culate the scale needed to fit the result=2E Does adding those two options = to all calculations mean adding them to calculations like add as well? That's why I mentioned the two different groups of users=2E The scale and = rounding mode aren't there for group (a), who just want the scale to be man= aged automatically; they are there for group (b), who want to guarantee a p= articular result has a particular scale=2E The result of $a->add($b, 2, Rou= nd::HALF_UP) will always be the same as $a->add($b)->round(Round::HALF_UP) = but is more convenient, and in some cases more efficient, since it doesn't= calculate unnecessary digits=2E=20 Remember also the title and original aim of the RFC: add object support to= BCMath=2E The scale parameter is already there on the existing functions (= bcadd, bcmul, etc), so removing it on the object version would be surprisin= g=2E The rounding mode is a new feature, but there doesn't seem a good reas= on not to include it everywhere as well=2E >- As Tim mentioned, it may be confusing to have an initial value separate= from the mode of the `round()` method=2E Would it make sense to have an in= itial value of HALF_UP? Again, the aim was to match the functionality of the existing functions=2E= It's likely that users will migrate code written using bcdiv() to use BCMa= th\Number->div() and expect it to work the same, at least when specifying a= scale=2E Having it behave differently by rounding up the last digit by def= ault seems like a bad idea=2E=20 Thinking about the implementation, the truncation behaviour also makes sen= se: the library isn't actually rounding anything, it's calculating digit by= digit, and stopping when it reaches the requested scale=2E The whole concept of rounding is something that we are adding, presumably = by passing $scale+1 to the underlying library functions=2E It's a nice feat= ure to add, but not one that should be on by default, given we're not writi= ng the extension from scratch=2E Regards, Rowan Tommins [IMSoP]