Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122746 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 C3C4A1A009C for ; Tue, 26 Mar 2024 11:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711452961; bh=Px1BL4osGFwdYh9HsLjCuyOBjMQLSQU3v0WDsbecrl8=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=H7pAUMxtK6x+D0pHVveuY2Dvqwv0/nhCpE+YmnkBBUmVgkgitm42a2I4VTcxx6VPL DLoUdkjPk6FOwtld/baZFIdMN5R7tPgIuU4P0HjUekCYgV3o7b7XvhzzwyNDT1OASx K8AA9MfYm7UYngPRNkJuNy4j7L0qkMRoLDl2i1ixkkhHkuvP5jRvFyxLzds6ArmQ0T RwI5GNT7Dv+LHLR8jN1YpRfj9RBRmZxzn8RR2iDuxXUl11L93M2kBgQqGoPN39ocAN im27QsPh181X9rNpTjKIBpuK+mRdJKhXBKeWiCceXQdmtj5fRrVvzjyYyI6QTJeVly Sg/UWIyM/vGuw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 16C31180004 for ; Tue, 26 Mar 2024 11:36:00 +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 ; Tue, 26 Mar 2024 11:35:59 +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 1C4B1401E7; Tue, 26 Mar 2024 20:35:32 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1711452932; bh=Px1BL4osGFwdYh9HsLjCuyOBjMQLSQU3v0WDsbecrl8=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=E6IlzfRLcGO3sGsUeB7okHyvwsw4RUhFUvjKgrcVUHCFOWmSoInAlItkFrcoDuRvs Ln0OXzOnF/zDZoTWsIWlQO6AJKcOI4lD93eWIKFF09/lhMkE3d5zCEMGN/z4Qw7lJo 4aPrBGxfW6A+t5VMhEW4zF3q1Ca+PsWlqG+EbUCc= Content-Type: text/plain; charset=utf-8 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: <38d69258-cdaf-45d3-ba52-dc1398301c8c@redmagic.org.uk> Date: Tue, 26 Mar 2024 20:35:19 +0900 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <5085240B-75B8-40B8-81B9-0E80B80B7C44@sakiot.com> References: <4F094EDA-5058-407D-AF39-06FD934FDE1F@sakiot.com> <38d69258-cdaf-45d3-ba52-dc1398301c8c@redmagic.org.uk> To: Barney Laurance X-Mailer: Apple Mail (2.3731.700.6) From: saki@sakiot.com (Saki Takamachi) Hi Barney, thanks for the points and suggestions! > Is there any reason not to give the BcNum class a public readonly = string `value` property? Would just save a few characters of typing to = use value instead of getValue(). > Also as with the value, any reason not to make the scale a pubic = readonly property? I had completely forgotten about the existence of read-only properties. = That makes sense. > I suggest renaming `setScale` to `withScale`. Although the docs will = make clear that the object is immutable, `set` is associated with = mutation and might be confusing. `with` is not as well known as a prefix = but is associated with immutable objects. Indeed, I felt uncomfortable using "set=E2=80=9D. I didn't know that = "with" was related to immutable. **I immediately reflected the above two points in my RFC** :D > One more suggestion - might it be worth adding a `format` function to = the new BcNum class? This would be similar to the existing number_format = function, but would avoid the need to lose precision by converting to = float first. I came up with the following code, is it close to what you intended? ``` $num =3D BcNum::fromNumberFormat(1.2345, 5); $num->value; // 1.23450 ``` Regards. Saki=