Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123089 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 861B01A009C for ; Wed, 10 Apr 2024 13:08:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712754521; bh=PFjBVVv3gEtt5JznYa8LfiiGVAa/Dhs8yQBZZNJipMw=; h=In-Reply-To:References:Date:From:To:Subject:From; b=RVBZE9KBh1MZVxw9wzm5u1o2efCeOQN6JXrklvdEZt7QR1l6uI9qCW/yfUL/BtZBp 6DOj8Yz47el0a0HmELtvFX6vOFfXu+UwTWogMqFc3dQkJsXS5vZe5EKsaOXcWg+s9d khH5kCl7xKBglPIGcf0UW+syyX92d+mzJdOvkfMo8xPINiEKM37SJuu2wAp5H567+u WBaWqvX0e5gg++oYE+xWBXwHRBImDKVR8/i2qS7dlnckGdYFDUh3S9mTN8KFsSj+M1 G3JoD4jQYatMFhQ5GLXegHJ3leUhiG27ZYTmZ781aQG0b/7qwRq/VFcfQZAYCE0dTK zMHkDATbp/5Bw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0006118007C for ; Wed, 10 Apr 2024 13:08:37 +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 fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (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 13:08:37 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 32CEA1380092 for ; Wed, 10 Apr 2024 09:08:04 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Wed, 10 Apr 2024 09:08:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :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=1712754484; x=1712840884; bh=Ad8xN0uKvY E/piDH0sAAOM9anRayC89ljuXG17D2C8M=; b=jUZCWPddo01g+iOgUJqAbEOvCp 7NzVRKAbDoKPKc1xp1uj0XQm72M3IHvT0uamYD1xTUcmT1HsqrMAlnZbsaoNSxJ9 lNSe5uYED0L0ulqdH3iKZHrTE7XGQs2GGzukMuHpe4jC8Ne62M9XbGbET8a2xZ4U ms3929RFFVRISNH0YwyFCcD8Jqu5gjGCZZdpqbw22aFW/iiK0PmX2/opNZEPI2wE blOQ7yKZkpiiM1gxt9ml8PSz50EH6FTo5uBA1rHkqOS34HzEWjMasxtmymns3VCX VsCszS35Ntd8CWg1iuos06nNUVtYv5IjmoVib5GausULpIg16LSCESCwnRKw== 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:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712754484; x=1712840884; bh=Ad8xN0uKvYE/piDH0sAAOM9anRay C89ljuXG17D2C8M=; b=lMx/krIvtMHZGTPQUEphNDiSKVeAiZpJXJnSMbaGCTQk jYGPev8rkGStYw7WvXEL0fdioLGaJTSUNh/ePO8F5ExW9jorYgwDDYcQfqYPu7/g mXB5pBXJxtAQPuPFN5mBUBtXCoO74+aQTtg1LcAce6IqpzndrHOroS//6NAR8CmQ kzpm3QEIRbysw+ZXuYtk9wnwQPRAOKVAYSOm172t4oekHt4RFIjy7Dy+R0i2rVXP DYuLL53J2PXJxkcvwVRkttGKXNgfqKl/FeZDFuNGw+0hJforigPyV+w2Onr84ELJ GlcifCRFddzpw3oIkpru/K71EncTYmjH1t9Kb+kyuA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudehiedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd hmtderredtnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdf uceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpe fhgfdufffhkeetvdduteejtddtgfefueelgfefuddvgeetheevleeileektddtudenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprd hphhhpsehrfigvtgdrtghordhukh X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B88801700096; Wed, 10 Apr 2024 09:08:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-379-gabd37849b7-fm-20240408.001-gabd37849 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <15702F55-16D1-43AD-88CC-BC703E267FFC@rwec.co.uk> In-Reply-To: <04F88690-82B6-4441-B155-C489EACD6DC5@sakiot.com> References: <04F88690-82B6-4441-B155-C489EACD6DC5@sakiot.com> Date: Wed, 10 Apr 2024 14:07:42 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath Content-Type: text/plain From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 10 April 2024 10:38:44 BST, Saki Takamachi wrote: >I was thinking about this today, and I think both are correct opinions on whether to set the initial value to HALF_UP or TOWARD_ZERO. It's just a matter of prioritizing whether consistency with existing behavior or consistency within a class, and they can never be met simultaneously. Yes, I agree there's a dilemma there. The extra point in favour of TOWARD_ZERO is that it's more efficient, because we don't have to over-calculate and round, just pass scale directly to the implementation. Any other option makes for unnecessary extra calculation in code like this: $total = new Number('20'); $raw_frac = $total / 7; $rounded_frac = $raw_frac->round(2, Round::HALF_UP); If HALF_UP rounding is the implied default, we have to calculate with scale 11 giving 1.42857142857, round to 1.4285714286, then round again to 1.43. If truncation / TOWARD_ZERO is the implied default, we only calculate with scale 10 giving 1.4285714285 and then round once to 1.43. (Of course, in this example, the most efficient would be for the user to write $rounded_frac = $total->div(7, 2, Round::HALF_UP) but they might have reasons to keep the division and rounding separate.) Regards, -- Rowan Tommins [IMSoP]