Re: Should base_convert raise a notice/warning on precision loss?
| From: | Sjoerd Langkemper | Date: | Thu, 18 Jun 2026 11:27:48 +0000 |
| Subject: | Re: Should base_convert raise a notice/warning on precision loss? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131368@lists.php.net to get a copy of this message | ||
On Thu, Jun 18, 2026, at 13:16, Morgan wrote:
> Alternatively, could the base conversion be made via bcmath to retain
> all the digits instead?
I agree this would make base_convert more useful, and it is technically possible to make
base_convert work with arbitrary large numbers, but this is hard to do in a backwards compatible
way. Users who currently create their session tokens or encryption keys using base_convert rely on
the loss of precision, and their application will break when base_convert is suddenly improved to
have arbitrary precision.
I guess it is possible to add a $precision=false parameter. That wouldn't win a beauty contest,
but it would make the new behavior opt-in and thus backwards compatible.
Regards,
Sjoerd