Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123053 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 955A21A009C for ; Tue, 9 Apr 2024 10:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712660011; bh=Varv/vsEuvV1xLG5PVoHeX72rh9IQJxQOW8mADcMch4=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=BkSkXRsd7p4s13TisdA8c+8EncdQmrMXgL5BWZISFBExxYs78Bvh9ZRXha+EMEGrO AHD1HLobr0/KrrakpvE6gbqsm2GZXwWFxvVdZVFBjTU0YqPQdLQsOkCVSd0klDnT2o PKug7JzYc/aek0icxfTRwMj3OyV9lFHQLagRFjxqTTgjpMq14/3/IxklbWUKeFmVVH HNF+Rgz12iI8TbzCVf8RX1+egkRm6GyalGqdgbCjkiNvWk26B6mtYW0N5+qoY+R8mS LdWRBcq+6ijDcGPFNbYdxKr9yRlP+yoOPm/KEwaT2nVQzTahW5WD7Cwxh6PE8HVH1A vPVcdike4V6jQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A00EF18005D for ; Tue, 9 Apr 2024 10:53:30 +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:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712659977; bh=Varv/vsEuvV1xLG5PVoHeX72rh9IQJxQOW8mADcMch4=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=HaC3QQUxkhyyebSTefZVINqXfICCHYwTgVzN+k6pXcr/GfODsrv1P8mRh1m7ozoBA sTI+PQifl/ycxjjV1pjEnCG6g5dMOlf4pv28T1kx1ZXWnS3VUNXnLtJexn2y4mKv6y XiccGTu6YAywdiEFJDv3PsxPgQOnUe44MZHTK5ezmo0l7gP/801r+vjSbqkVwscH70 sCVeoPeCTcGC1b9IuhWKjF/pO/0jSktbyxCgPi00MdnItZVycGSXutr6iShR60NuQR zPOIvICHFxhZ9DuWW1bGwWoGTdTAeZRu3wxX8hJhZ/6HS9HyFb1wNfTpl+n4XXiR9O v1JgkM2Ql1x0g== Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 8133010C051; Tue, 09 Apr 2024 11:52:57 +0100 (BST) Date: Tue, 9 Apr 2024 11:52:57 +0100 (BST) To: Alex Pravdin cc: internals@lists.php.net Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type In-Reply-To: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> Message-ID: <0f64523d-d949-75ed-682b-789fc33fa3b2@php.net> References: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> 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 Thu, 7 Dec 2023, Alex Pravdin wrote: > Accounting for all of the above, I suggest adding a native numeric > scalar arbitrary precision type called "decimal". Below are the > preliminary requirements for implementation. Adding a new native type to PHP will create a large change. Not only is it "just" adding a new native type, it also means all of the conversions between types need to be added. This is not a small task. > Decimal values can be created from literals by specifying a modifier or using > the (decimal) typecast: > > $v = 0.2d; > $v = (decimal) 0.2; // Creates a decimal value without intermediary float > > It uses the precision and scale defined in php.ini. If you want to use arbitrary precision natives, then a precision and scale as defined in php.ini defeats the purpose. Every installation can then potentially calculate things in a different way. The only way how to prevent that, is to have *actual* Decimal type, such as the Decimal type in MongoDB uses (the IEEE 754 decimal128 type): - https://www.mongodb.com/docs/mongodb-shell/reference/data-types/#std-label-shell-type-decimal - https://en.wikipedia.org/wiki/Decimal128_floating-point_format 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