Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123027 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 57B341A009C for ; Mon, 8 Apr 2024 00:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712534987; bh=FVe1Lg1E4h/IdipLVKn4pXGuV9PfB8u/QWtXlbtwzMY=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ICE3c2rCNNCgSnVUQs2yDtx4xozszKgpd/Q9iY419TIVzAqRbgNOtt0waq7kI/a37 MUtAHKPDl0RqI9gAJ3DoPyQ0qG+0+6L+3WE3/hHesYTlhHZn/ExLJFDTK9y98P9GYl yqPspVFwtAsMw3t5vYbtAmVsdbn0XyynZo5cZGoCz69LRlvzwVsh2rFB+nY7twN8i6 bYHosOqixTt14yMbDOIK/ekxEy42M9WXzW4AQDuB6nFozkfc5fKdM5JDNHgXWUFQrA +QCN6M+FOM7uzVywN6ro8idxOX6s4U2qJb6IrsIXDLiB3vjjIS6ai1N/W+iQ8Z0U7f 77nvGV9yFVxcA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 47F1418007A for ; Mon, 8 Apr 2024 00:09:45 +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 ; Mon, 8 Apr 2024 00:09:44 +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 751E6401D9; Mon, 8 Apr 2024 09:09:09 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1712534949; bh=FVe1Lg1E4h/IdipLVKn4pXGuV9PfB8u/QWtXlbtwzMY=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=a30XdkhfLp92lgtUy/+XhsUIWbcbzb8mcsHoB0s09MdIs7YyYfXwYbh8+U3RTDkKi OLNJ5Jjn1sHtEGbWiAyFJEI6xS6TDZgBdTzybEImjF+oevEHZknSBsdD/Y1oi+XzK5 nrY0gRCwcTt77n5Vj+TSSMiNRajlWcyhTRGSe1cw= 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.1.1\)) Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath In-Reply-To: <959ccc6e-1d5c-48c0-9357-80e38becd1c5@bastelstu.be> Date: Mon, 8 Apr 2024 09:08:56 +0900 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <959ccc6e-1d5c-48c0-9357-80e38becd1c5@bastelstu.be> To: =?utf-8?Q?Tim_D=C3=BCsterhus?= X-Mailer: Apple Mail (2.3731.700.6.1.1) From: saki@sakiot.com (Saki Takamachi) Hi Tim, > - The namespace is inconsistently referred to as "BCMath" and = "BcMath", please check the entire RFC to unify the casing. Thanks, I fixed it. > - The full =E2=80=9Cstub=E2=80=9D should probably include an explicit = "implements Stringable" for clarity. Agree. I describe it explicitly during implementation. > - I don't want to expand the scope of your RFC further than necessary, = but for the rounding mode, I wonder if we should first add the = RoundingMode enum that has been suggested during the discussion of the = "Add 4 new rounding modes to round() function" RFC. It would make the = type for the `Number::$roundMode` property much clearer than the current = `int`. I expect the addition of such an enum to be a pretty simple RFC = that would not need much discussion. I'd be happy to co-author it. Oh, that's a good idea. Makes sense. I think it would be simpler to = prepare an RFC separate from this RFC, so I'm going to create one right = away. Once you have a certain amount of content, I would be happy if you = could check it out and make corrections if necessary. > - The property should probably be named "$roundingMode" instead of = "$roundMode". Thank you, I'm not a native speaker, so pointing out English expressions = is very helpful. I fixed it. > - I'm not sure I like the differing default rounding modes for = implicit rounding (i.e. the $roundMode property) and explicit rounding = (i.e. the round() method). That sounds like it would cause unnecessary = confusion. I missed the point. All defaults have been changed to HALF_UP. > - In the stub there's a typo: "puclic", should be "public". Oops, thanks! > - For `format()`, I'm not sure whether we should actually add the = function. While we have number_format() for regular numbers with the = same signature, it fails to account for the different language and = cultures in the world. Specifically `number_format()` cannot correctly = format numbers for en_IN (i.e. English in India). In India numbers are = not separated every three digits, but rather the three right-most digits = and then every two digits. Here's in example: 1,23,45,67,890. I believe = formatting should be best left for ext/intl. I'm not very familiar with ext/intl, but is there a way to format a = string type number without converting it to a float? > - I'd probably not add the 'with()' method, because it would be = redundant with https://wiki.php.net/rfc/clone_with and it can already be = specified by a combination of withMaxExpansionScale + withRoundMode. I see, I wasn't aware of that argument. Removed `with()`. > - I'm not sure if the priority for the rounding modes is sound. My gut = feeling is that operations on numbers with different rounding modes = should be disallowed or made explicit during the operation (much like = the scale for a division), but I'm not an expert in designing numeric = APIs, so I might be wrong here. As mentioned in the RFC, the problem here is commutative calculations = (add, sub, mul). This means that even if specify `$roundingMode` during = these calculations, `$roundingMode` will not be used in these = calculations. Calculations that use `$roundingMode` are divs, etc. If = allow `$roundingMode` to be specified with add, intuitively it feels = like the result of add will be rounded. Also, it is not possible to specify `$roundMode` in calculations using = operators. However, if the user calculates two numbers with different rounding = modes, and it is intentional rather than a mistake, I can't imagine what = kind of result the user would want to get. Therefore, it may be better = to make this an error. Is it appropriate to throw a value error in that case? > - For the RFC Impact on SAPIs, it should simply be "None", because = SAPIs do not need to do anything special. I fixed it. > - For the Backwards Incompatible Changes, it should list that the = BcMath\Number class will no longer be available to userland. I added that. Thanks! Saki