Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122758 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 E2BE51A009C for ; Tue, 26 Mar 2024 15:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711468106; bh=W52vIhE2JoyaxSv44dfUN7AvEEa8rvg9LrvyyPZAleg=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=L17A8GCH/KwjkkYH0maGmVpUbVOyfpSx1/4Krjv7EMDA0F/aiBr5ywQ8JAT7jyg86 MODYCbiVXXEkxVMATC7LogsDJ50AaEhTlCc+wm5FjDlI6or2O2QG4aM9Blvh29x5lY 9Kgc2s17o762DkYA5K+hGdcK9oxrgPQhM8boZtkiC/Pte/qYStmlTpJORUQuT9Im1j FuB7dZkdjdJmZhy2moFDfPfFnCItBIYqj0el39TmjTjNfsmI6nBBq7A/ls1oN03MUT ALfylYXmm8n3C9Qk1hv9g4PT0EuouLWQMWFQlxsbkddm3Jfx1SfSUSnbwlmYUez2Uq YPAAsNnM0Y8PA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EEE8118076E for ; Tue, 26 Mar 2024 15:48:25 +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=2.3 required=5.0 tests=BAYES_05,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, 26 Mar 2024 15:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1711468080; bh=W52vIhE2JoyaxSv44dfUN7AvEEa8rvg9LrvyyPZAleg=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=MYJAQB/ohErJUwvlku7rGypJqXCoz48QEwFiopTPjyKB6DvsSAIT750kQm4sgBtPP 0WdNc2WRpWlMOMbQSIJLxMj0vP5ZtwXjIsZSmgmzOqU+T5XSLW87ZG5V5DIHj8ymcu yOCACMo8XyjT/cwpGGI4preUwmADOWacVFX1eg9kmgtPEssiNrEAz8JjoH2NuuymS3 xszv+Mxo73D7q9Uwl8PS7uGsFhkZz4xQpxg6gH9K3hiEodCybqIAHiHxWE8AzRQBLd L6PVU0M4P6N16djJV0os0D72RMsslPNHIMeU+A8HGXcT35D+mUSar+VlCQuDMweZur WZSj9efZLO25Q== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id D3D2C10C182; Tue, 26 Mar 2024 15:47:57 +0000 (GMT) Date: Tue, 26 Mar 2024 15:47:56 +0000 (GMT) To: Saki Takamachi cc: php internals Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath In-Reply-To: <4F094EDA-5058-407D-AF39-06FD934FDE1F@sakiot.com> Message-ID: References: <4F094EDA-5058-407D-AF39-06FD934FDE1F@sakiot.com> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII From: derick@php.net (Derick Rethans) On Sun, 24 Mar 2024, Saki Takamachi wrote: > Hi internals, > > I want to start the discussion on the PHP RFC: Support object type in BCMath. > > https://wiki.php.net/rfc/support_object_type_in_bcmath I have some comments: - You've picked as class name "BcNum". Following our naming guidelines, that probably should be \BCMath\Num (or \BC\Num, but that is less descriptive): https://github.com/php/policies/blob/main/coding-standards-and-naming.rst#namespaces-in-extensions The reason it *should* have "BC" is that it comes from "Basic Calculator" (https://www.php.net/manual/en/book.bc.php#118203) - Should ->value rather be ->toString() ? ->value alone doesn't really say much. I'm on the fence here though, as there is already (internally) a ->__toString() method to make the (string) cast work. - Would it make sense to have "floor" and "ceil" to also have a scale, or precision? Or would developers instead have to use "round" in that case? - Which rounding modes are supported with "round", the same ones as the normal round() function? - In this example, what would $result->scale show? (Perhaps add that to the example?): value; // '2.46456' $result->scale; // ?? - Exceptions The RFC does not mention which exceptions can be thrown. Is it just the one? It might be beneficial to *do* have a new exception hierarchy. cheers, Derick -- https://derickrethans.nl | https://xdebug.org | https://dram.io Author of Xdebug. Like it? Consider supporting me: https://xdebug.org/support mastodon: @derickr@phpc.social @xdebug@phpc.social