Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123054 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 3B7C01A009C for ; Tue, 9 Apr 2024 10:59:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712660376; bh=Or773CELNS/nBtoH0XEwsBT13uvxJrHKd+4UsJj2728=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=E2JGLOJmao3XAq3iG5kf+Zzc07xZXjOakVEq5QS3fS4E8dKl7QY8tg3ZqKIcCDO4r K9XAC3tSSYHrPgFaizIGvRDYxAXwQhyFl1ZYbeB9ulSwVNJ+4wpAa74hADMlkCOjIQ cw4E93y98uahkn0SwE4zBNtbEeCWt1UIraoap4guV8R4mbqLlXtob/SuwUnjw1kABE VDT8RgfrdVP7qaRCaEYLSo3gto6fGXRCpixkyQQyPpjjF6qsz0Zj15X//Sv7p07WOu nFkPBkisoIix4FM90K4FVkv472sD3Y1E9dFSHX104Hl2ZshcFOOP+JqA5w4cDtShNT nH5qRrzmDSE/w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F63218005D for ; Tue, 9 Apr 2024 10:59:36 +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=3.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,SPF_HELO_PASS, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from xdebug.org (xdebug.org [82.113.146.227]) by php-smtp4.php.net (Postfix) with ESMTP for ; Tue, 9 Apr 2024 10:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712660343; bh=Or773CELNS/nBtoH0XEwsBT13uvxJrHKd+4UsJj2728=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=LrGWCFgt2/oOeG3w0W5efsPWUOzqu5COliRuBMwj4VUp9YPfI3B0xk5kbIfXs2rE6 PvZKXueoIxbux4PK4t//CM9qab/dvVN5BogE3egw73whU/Zo1T1oC8XhRPHWMjMTix pdakuznjEj/RIZG7ERFuXMzclxVoimainWFO52wbJ6VXUPOWPpFTIxI7NTaSpJpIxs XMpqkBfjB1DcAx19cjWCvHSqMSA5hunOGxVbgXNfEwgnDiBFXfCCIKS3ML49rKS0Ll 5OVzUsQCScJggktrG5XCp6R4CxeT8jdCoos0YuuH6O8Am58mza7RMEsI7SLaDoSLsL FhbHGjrLrvrNQ== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 8061D10C051; Tue, 09 Apr 2024 11:59:03 +0100 (BST) Date: Tue, 9 Apr 2024 11:59:03 +0100 (BST) To: Jordan LeDoux cc: "Rowan Tommins [IMSoP]" , internals@lists.php.net Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type In-Reply-To: Message-ID: References: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-861573137-1712660343=:26150" From: derick@php.net (Derick Rethans) This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-861573137-1712660343=:26150 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 3 Apr 2024, Jordan LeDoux wrote: > On Mon, Mar 18, 2024 at 1:35=E2=80=AFPM Rowan Tommins [IMSoP] > wrote: >=20 > > > > Where things get more complicated is with *fixed-precision* decimals, > > which is what is generally wanted for something like money. What is the > > correct result of decimal(1.03, precision: 2) / 2 - decimal(0.515, 3)? > > decimal(0.51, 2)? decimal (0.52, 2)? an error? And what about decimal(1= 0) / > > 3? > > > > If you stick to functions / methods, this is slightly less of an issue, > > because you can have decimal(1.03, 2)->dividedBy(2, RoundingMode::DOWN)= =3D=3D > > decimal(0.51, 2); or decimal(1.03, 2)->split(2) =3D=3D [ decimal(0.52, = 2), > > decimal(0.51, 2) ] Example names taken directly from the brick/money > > package. > > > > At that point, backwards compatibility is less of an issue as well: mak= e > > the new functions convenient to use, but distinct from the existing one= s > > > I came back to this discussion after my last reply on the BCMath as an > object thread, because we went through a very similar discussion there wi= th > regard to operators. >=20 > I think that, roughly, the fixed precision should be defined on the scala= r > itself: >=20 > 1.234_d3 >=20 > 1.234 is the value, _d makes it a decimal type, and 3 shows that this val= ue > has a precision of 3. (Actually, it has a SCALE of 3, since precision is > significant digits, and also includes the integer portion). But when it > comes to fixed-precision values, it should follow rules very similar to > those we discussed in the BCMath thread: Woound't it be much better to capture this complex information in an=20 Object, and then allow operators on this? Like... Saki was pretty much=20 suggesting with her BCMatch/Number class RFC? I can't imagine people looking at code understanding a syntax like this=20 right away, let alone of what it all means. cheers, Derick --=20 https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/suppo= rt mastodon: @derickr@phpc.social @xdebug@phpc.social --8323329-861573137-1712660343=:26150--