Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121943 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 58455 invoked from network); 7 Dec 2023 11:26:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Dec 2023 11:26:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4361C180035 for ; Thu, 7 Dec 2023 03:26:57 -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=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 03:26:56 -0800 (PST) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-5b383b4184fso5346447b3.1 for ; Thu, 07 Dec 2023 03:26:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interi-co.20230601.gappssmtp.com; s=20230601; t=1701948402; x=1702553202; 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=gqDpW/AtwTA5v0vne5oMQhXuR3Nqtkxo0prw57muNQc=; b=HNDT8ZPszXURyp4TwR8cM3gnJNpXKxFXlG/qjChF21YJhxcEc8WI65EiXZGcF3DMKJ lnuoThoNBDgrNMbdVdYnVCH03HD2U19EwQ9oNOE6qPtmHP2/DAc6C3aowJH6VD0lMga0 30o25haysc3wG5dX698CCOVVHPZcwhF0R1Xhmf6eHA21loRQAhwmJtt8JetoK00AEYQd 2Ak3IfyO6yjXOjzwSa9J8eK1PFMBdCq6cEgWi4w3oHAgHNWY5auKuEApU96BjOAAjZO8 AigVNeSJIjcwMfuMFzF6ougeN07ogsM3ucoKN6nRp5kV6ioQYIU1uZ5tvDV2BMm6TMH0 SXAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701948402; x=1702553202; 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=gqDpW/AtwTA5v0vne5oMQhXuR3Nqtkxo0prw57muNQc=; b=dM7/ZvFbR4XWEZBQg0Y3jz+E/z4blQuNHJxB96FxURIwyJklfphNfLx2sf62KHGWSC qvpzmZX9Ngn43W9dlIplS3sbFRXOOefD4Y3Mmu8AFkS82RFq5flc0JHiL6EluYT9yhJH 6SWKlTDMg7wUakFpPnNlgjPsKACGwol75EXZPA/QJVKQpkfRG7T2PD2nWK2wmVCI02Za p9yRRlMevNPXlyTxissj39kft/4L72YDI2zb1iFAQCIlVKiqsVvAc4QRI4xqlT4RXMn+ aTE2DFBccOD2/A0wXXz7PvW6AxebBIl0HIQ/2g7TJ4hB/Poa2AMBGV2IumUVh5pKa2Ja NCPA== X-Gm-Message-State: AOJu0YzqVJULzIxYsJWZWtC706VakMXOYxC9yc1Y+irWqcUakULCaSMV Uz07xORCkbAei1J4yj+26HEVdhe7UFwLmgGOx79aCw== X-Google-Smtp-Source: AGHT+IH3yf+rTpSmoc+FfzsKB3rlq04WGpwNfpRnNCg8Jhig4Z4Qn+rl3cMLVWjS+4Fic3W56lXw8bQFOEQ8bIqs+lc= X-Received: by 2002:a81:7e51:0:b0:5d7:1940:7d62 with SMTP id p17-20020a817e51000000b005d719407d62mr1859589ywn.57.1701948402568; Thu, 07 Dec 2023 03:26:42 -0800 (PST) MIME-Version: 1.0 References: <18c42fdbb30.2831.17a3710df6d58f02ca570cc47e197a63@interi.co> In-Reply-To: Date: Thu, 7 Dec 2023 20:26:30 +0900 Message-ID: To: Ben Ramsey Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary="000000000000f625a4060be9bdf7" Subject: Re: [PHP-DEV] Proposal: Arbitrary precision native scalar type From: alex.pravdin@interi.co (Alexander Pravdin) --000000000000f625a4060be9bdf7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > > Someone tangential to your proposal, have you given any thought to > implementing this similar to how Python treats numbers? > Unfortunately, I don't know many details of numbers treatment in Python... In Python, integers have unlimited precision. I=E2=80=99m not sure how they= store > the values internally, but to users of Python, any sequence of numbers is > an `int`, no matter how long it is. > > For example, this multiplies the max 64-bit, signed integer by 2, and the > result is still an `int`: > > >>> i =3D 9223372036854775807 * 2 > >>> i > 18446744073709551614 > >>> type(i) > > > And this is a really, really, really long number that=E2=80=99s still an = `int`: > > >>> x =3D > 9223372036854775807922337203685477580792233720368547758079223372036854775= 807 > >>> x > > 9223372036854775807922337203685477580792233720368547758079223372036854775= 807 > >>> type(x) > > I'm not sure about integers, I mostly care about decimals :) Decimals can hold big rounded ints as well. The limit on the maximum number here will be the underlying library's limit. However, if we can achieve arbitrary-length integers, is there a reason we > couldn=E2=80=99t also have arbitrary length floating point numbers? > I'm not familiar with arbitrary-length integers so I don't know what to say here... > Below a certain threshold, we could use the system=E2=80=99s native int a= nd double > for storage and math. Above a certain threshold, we could internally swit= ch > to a bundled library for handling arbitrary-precision integers and floats= , > and it would be seamless to the user, who would see only `int` and `float= ` > types in PHP. > I guess this could be a topic of the next step discussion after "decimal" introduction. Anyway, this is something I=E2=80=99ve been thinking about for some time, b= ut I > haven=E2=80=99t taken the time to look into what it might take to impleme= nt it. It > sounds like you have looked into it, so I=E2=80=99m interested to know wh= ether you > think what I=E2=80=99ve described here is feasible. > I was only thinking about decimals and I'm not an expert in low-level manipulation of numbers. Best regards, Alex. --000000000000f625a4060be9bdf7--