Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123012 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 3CAE31A009C for ; Sun, 7 Apr 2024 13:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712496472; bh=yerijTl55Pb6ngwYbGUDpzYOEJiBHDSea+XidLSK4uk=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=fWD7rtIytG1Fcd+IE7sL9NkZ67FuUz2xSkKd4lZc49fMxoTM/VLgtxuYjI8heDInX U7WY8C8exkbsyZPDUDgjLE6XHt9S7Ny4JfPF5xkQ7jNffzRqdxKLDLn0T8/qXdAkbA UNBF0kE/rUE63DCx00In3XumLai+IfSXos8yorB3LZr+XGnpVi9SwS9/9OCKQ0tdU0 5Rk2/nFF57v+eyiIfexB7lSn9GKlraKM9GyqTziClcY3B1K5Q9Y1P6CwRFECly4esA xnNUj9NkW4DRMFT5V2II+HfZAeB8i3L4jxwBWda4s/hJhDgJ9h8gg2Zd7TiyJh5z0l cd/+gBVGKr7yA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 619AB18006D for ; Sun, 7 Apr 2024 13:27:51 +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,HTML_MESSAGE, MIME_QP_LONG_LINE,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 ; Sun, 7 Apr 2024 13:27:50 +0000 (UTC) Received: from smtpclient.apple (193.211.49.163.rev.vmobile.jp [163.49.211.193]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id 6836E401F4; Sun, 7 Apr 2024 22:27:15 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1712496435; bh=yerijTl55Pb6ngwYbGUDpzYOEJiBHDSea+XidLSK4uk=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=Tw+Qz01yq+ubGWNKfTh2/XhyZ8pzFyN+7Ehtp0i354WEoc11dn8F56hRkl5pidUio Puw81BArB5fv9yVGH61H46a1EWhv52BzsI8H4ZYfj5pMMwu1tw75nhBwQd7vDv4zNS 2UxR/NAsSTKw3HcJjMlHVuvg97V2iPezoFW0XPtY= Content-Type: multipart/alternative; boundary=Apple-Mail-58604A75-71A6-475D-8A7A-75EB5120545F Content-Transfer-Encoding: 7bit Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (1.0) Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type Date: Sun, 7 Apr 2024 22:27:02 +0900 Message-ID: <494F7C68-81FC-49DE-A292-A782F7C79DB1@sakiot.com> References: <3c74f433-be6b-4f20-beb0-f09db2fb39b6@rwec.co.uk> Cc: internals@lists.php.net In-Reply-To: <3c74f433-be6b-4f20-beb0-f09db2fb39b6@rwec.co.uk> To: "Rowan Tommins [IMSoP]" X-Mailer: iPhone Mail (21D61) From: saki@sakiot.com (Saki Takamachi) --Apple-Mail-58604A75-71A6-475D-8A7A-75EB5120545F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, > What I'm saying is that $x / 2 doesn't have a good answer if $x is a fixed= -precision number which can't be divided by 2 without exceeding that precisi= on. You need a third operand, the rounding mode, so you can't write it as a b= inary operator, and need some kind of function like decimal_div(decimal $div= idend, int|decimal $divisor, RoundingMode $roundingMode). How you implement "= decimal" doesn't change that at all. >=20 IMHO, if need a parameter that is anything other than a pure value, it's a b= ad fit for a native type. It's just a different notation for creating instan= ces. If we really wanted decimal to be a native type, then the rounding mode and s= cale behavior should be completely fixed and not user selectable. If not, de= cimal should be implemented as a class. In fact, php's float will round valu= es =E2=80=8B=E2=80=8Bthat are too fine, and cannot specify how it will round= them. (This involves CPU floating point modes, but I wanted to keep it cons= istent so I just gave it as an example.) Regards. Saki= --Apple-Mail-58604A75-71A6-475D-8A7A-75EB5120545F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi,

What I'm saying is that $x / 2 doesn't have a good answer if $x is a= fixed-precision number which can't be divided by 2 without exceeding that p= recision. You need a third operand, the rounding mode, so you can't write it= as a binary operator, and need some kind of function like decimal_div(decim= al $dividend, int|decimal $divisor, RoundingMode $roundingMode). How you imp= lement "decimal" doesn't change that at all.

IMHO, if need a parameter that is anything other than a pure value, it's a= bad fit for a native type. It's just a different notation for creating inst= ances.

If we really wanted decimal to be a native t= ype, then the rounding mode and scale behavior should be completely fixed an= d not user selectable. If not, decimal should be implemented as a class. In f= act, php's float will round values =E2=80=8B=E2=80=8Bthat are too fine, and c= annot specify how it will round them. (This involves CPU floating point mode= s, but I wanted to keep it consistent so I just gave it as an example.)

Regards.

Saki
= --Apple-Mail-58604A75-71A6-475D-8A7A-75EB5120545F--