Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121944 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80115 invoked from network); 7 Dec 2023 14:27:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Dec 2023 14:27:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C82F318004F for ; Thu, 7 Dec 2023 06:28:03 -0800 (PST) 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 ; Thu, 7 Dec 2023 06:28:03 -0800 (PST) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so762328a12.1 for ; Thu, 07 Dec 2023 06:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701959269; x=1702564069; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=73Udf65wE9dspxwKy+1cElIbtHH0I6aF4tapL12PpkI=; b=ILb2Mq14O5cuAwU/97wnoCNrxl0t4v4LEE7JQxfcU1kD6rZrVIQq/p42Uo3pnF2Qh2 SjljOjx4ahiQ1i51CbVwyidBVRrlTe98kJPN5QLBmLIlAk4S29oOxrN49jiEh9114PQP XGi6rtXKakRMLeASrTjPDYnD1xw1Qouqt0DmgBj0y93q7yntjZeON/jh3FaIubhanNNz G/tdTulefsrquFq39oRRrPFCpd4ylR7UKZYX71pXFETxW8Ksa9R8kdjaSEus6Qp7SMTF LzLZkyMtXvsynYUeOR86VcPWyo4G0LZBmk/93lJ0eVPDh2cJLdsywKP5tXmeA+tRl3hY pDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701959269; x=1702564069; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=73Udf65wE9dspxwKy+1cElIbtHH0I6aF4tapL12PpkI=; b=bHGyTvOVnOCN31Re5lANBm4W1Tq+pFZwuzkRzztCPDD71igmG5+kCmuqp6eD3JdFx0 i6Oycre6zmM8cpkjeBNsH48X6Yr8JfI3G2z4ROrIG6FmerdAxnuu96uLMXZDXpN3yveg h0l0kyGidyz98WdSr2ZOMQU4TWz+wTJnDQhzlBNopVqa8oa7FlzBpN3kvY74LbV8rB7L Kuhl0V8ZfsvMjkMBmwN2oU7V2F71vC8Vpu//rhtemYig6LSWIqjLzoqwmMJSzfbD/BWA YmCl9NKjpcZor/kwIgTogy2bXBK36ZwiAm89g8hQVn8GNAVXTFP2W+FXlGyQQVSdun63 cIzQ== X-Gm-Message-State: AOJu0YxwQfda5flo0TEP3dnZXCY6DzfnvqHGaDt5NDKS6AVHWW5Zahpd bzsYm2tv8k8wuFl72+Nfdt7o32kXHrjdLW9U9KIeIG3q X-Google-Smtp-Source: AGHT+IH5LOneoKm48TgskfZ2HL/JMwbHQbiw9Wk1avxvQ8hryjfjRIsOtVjQQ6XgopDfyCU0ppHsWP+724RPQD9O9QM= X-Received: by 2002:a17:90b:4a11:b0:286:6cc1:3f14 with SMTP id kk17-20020a17090b4a1100b002866cc13f14mr2635850pjb.75.1701959269012; Thu, 07 Dec 2023 06:27:49 -0800 (PST) MIME-Version: 1.0 References: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> In-Reply-To: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> Date: Thu, 7 Dec 2023 06:27:37 -0800 Message-ID: To: Alex Pravdin Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000a6da92060bec4544" Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type From: jordan.ledoux@gmail.com (Jordan LeDoux) --000000000000a6da92060bec4544 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 6, 2023 at 10:36=E2=80=AFPM Alex Pravdin wrote: > Hello internals, > > > This is the second round of the discussion regarding arbitrary precision > scalar type integration into PHP. The previous part: > https://marc.info/?l=3Dphp-internals&m=3D168250492216838&w=3D2 was initia= ted by > me before deep diving into the work with decimals in PHP. After 6 months > of > working, I would like to update my proposal taking into account my > experience and the previous discussion. > All builtin functions that currently accept float also accept decimal. So > users don't need to care about separate function sets, and PHP developers > don't need to maintain separate sets of functions. If such functions get > the decimal parameter, they return decimal. If they have more than one > float parameter and mixed float and decimal passed, decimals converted to > float by default. If "default_decimal" or "as_decimal" used, float is > converted to decimal with the warning. > > You are going to run into some very difficult corners on this one. For the last... 8 years i guess? I have been working on an arbitrary precision library for PHP in userland. It utilizes BCMath, ext-decimal, and GMP, depending on what is installed and what kind of operation you are performing. So, the functions that currently accept floats include functions such as `sin()` or `atan()`. These functions are not at all trivial to do to arbitrary precision. In fact, the VAST majority of the work I have done on my library has been to handle cases like "What do I do if the user wants 2.921 ** 4.293810472934854?" or "How will I guarantee the precision that the user requested for `tan()` in an efficient way?" Now, libmpdec is going to actually have implementations for most of this stuff that you can call directly, but if the PHP function `sin()` isn't capable of *outputting* a `decimal`, then this isn't really that much of an improvement over the current situation. I mean, it's still something I would support, but that's the area where some help from the engine goes a VERY long way. You're probably also going to need a way for a user to grab certain constants to a given precision. I would think e and pi at the least. I have a lot of experience working on this problem space in PHP, and am definitely willing to help. I looked into doing a libmpdec PHP integration several years ago, but decided that voters were unlikely to give it a fair shot, and so decided against it. If you're willing to try and roll the ball up the hill though, I'll definitely help you. Jordan --000000000000a6da92060bec4544--