On Thu, 27 Apr 2023 at 09:18, Claude Pache <claude.pa...@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` 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]