Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122775 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 57DD71A009C for ; Wed, 27 Mar 2024 10:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711536407; bh=MUoreQQwPmrRUdGxUW9TWXeNWnbWpVYRKWbvkaF2Njs=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=nNy4xMMsB7p/zqIxbiuuJszTuOpD766O2oF6d+y0P9QN7AylqOP61W4WPAv79xZnL NSfIysCOewDlANk7Nc8hJGW0ukUzzrtPd40z2rehOXSbaJCCwxMvpP5u5RrsTs1bAk LIYduT/r+WDHoO+FtoJh9LZ6iccjlqxhclBF04EJdxsRYAa7hIc2MRQfgnXB3ejqY1 Vu/8SmmtPW+YzD2rpMMHlUE9/amGEfoHo53gILITdKrutaw2ivRv6/iTAa9LQ7Uiei B/C/oEvltr8sVfSgH0jt/xMT52BGQX6J8y72ZBtGDMKQIGGpX73OjxMy/z4Icw5YQx fi9yG8aeHpQ9A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1100318005F for ; Wed, 27 Mar 2024 10:46:46 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,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 mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (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, 27 Mar 2024 10:46:45 +0000 (UTC) Received: from smtpclient.apple (unknown [117.55.37.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id ACAAA401E7; Wed, 27 Mar 2024 19:46:17 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1711536377; bh=MUoreQQwPmrRUdGxUW9TWXeNWnbWpVYRKWbvkaF2Njs=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Mn1SnsolBR2NC4EJZ9oTi7wLMQMT4T1nO4P07x7oYjwJMWIWmer02vOdUBrfwDZbi 8XT4i3Cqx/8OD7d5uKtRA9dKmpbh9qspd77v0TFgLNdjNKO6A8PYARKh9uIuieft+N YOFbN6X4n5E3gp0W82DGYEGqNl20xBsIKm5Nv71I= Content-Type: text/plain; charset=us-ascii Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath In-Reply-To: <904197f4-afb5-401e-9e17-7a655c5449d0@alec.pl> Date: Wed, 27 Mar 2024 19:46:05 +0900 Cc: php internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <4F094EDA-5058-407D-AF39-06FD934FDE1F@sakiot.com> <68CF373E-6ABF-4471-8992-813B4BA1B508@sakiot.com> <904197f4-afb5-401e-9e17-7a655c5449d0@alec.pl> To: Aleksander Machniak X-Mailer: Apple Mail (2.3731.700.6) From: saki@sakiot.com (Saki Takamachi) Hi Aleksander, > If you write it as: >=20 > $result =3D $num->withScale(4)->add($num2); >=20 > it's not an extra line anymore. I also think that withScale() use will = be rare, as we have the scale in constructor. >=20 > I think the intention is more clear here, and I think it applies to = all cases you mentioned, including div or pow. If you know you need to = change the scale just add ->withScale(X) before. Ah, that's right. I wonder why I forgot about method chaining. Update = RFC. If we miss something and $scale is needed, I can always revert the = RFC. > I'm not sure I like this. Maybe we should be more strict here and = treat the $scale in constructor (and later withScale()) as the actual = scale for all operations. >=20 > So, in the case above I'd expect ->scale to be 2, and ->value to be = '2.46'. If I wanted $num to have a scale that may change, I'd not define = it in the first place. Does that make sense? >=20 > ps. that also means withScale(null) should be possible. I see, that may indeed make sense. Now here we have three choices about = it. In fact, if want to behave like the current RFC, we can do it by = calculating as `$num + new Number($str)`. Yeah, I'll fix the RFC for this. Regards. Saki=