Re: Proposal: native decimal scalar type support

From: Date: Thu, 27 Apr 2023 12:08:35 +0000
Subject: Re: Proposal: native decimal scalar type support
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-120143@lists.php.net to get a copy of this message
On Thu, 27 Apr 2023 at 09:18, Claude Pache <claude.pache@gmail.com> wrote: > > This is the the description of the PHP Decimal extension, which does > indeed the Right Thing. But BCMath (which is not PHP Decimal) does have > “mind-blowing counter-intuitiveâ€� issues (at least in strict_types=0Ò > ìgÐ÷­R`­œ0V@‹ mode) > with floats. Formally, the root of the issue is in PHP type juggling, not > in bcmath itself; but from a user perspective, it doesn’t matter. > Specifically, passing a float to the bc*() functions will “workâ€� most of > the time; but in rare cases, when PHP decides to use the scientific > notation while casting it as string, it will fail with an “argument is not > well-formedâ€� error, which is puzzling for the unprepared user. > Fair enough; I've never used bcmath, so was lacking the context of that remark. I still don't think it justifies the "mind-blowing" and "band-aid" hyperbole, though. It could give better errors, but the solution is still "never initialise decimals from floats", and that would be true whatever was built into PHP. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#120143) next »