Re: Make bcmath functions more strict

From: Date: Fri, 26 Apr 2019 06:57:11 +0000
Subject: Re: Make bcmath functions more strict
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-105453@lists.php.net to get a copy of this message
On Thu, Apr 25, 2019 at 12:35 PM Benjamin Morel <benjamin.morel@gmail.com> wrote: > > Hi Vladyslav, > > I just checked your code snippet, here are my 2 cents: > > - bcmath should definitely trigger an error when encountering a malformed string like '17 > .123', silently converting it to zero is indeed the worth thing to do; > - I don't think that there's much value in having it handle exponential notation, you > can use userland libraries such as brick/math for this; > - I *really* don't think that it should depend on the current locale, like PHP sometimes > does with numbers; there has been some discussion just a few months ago to actually stop making > float-to-string conversion depend on locale: > https://externals.io/message/103638 > > Ben > > On Thu, 25 Apr 2019 at 11:02, Vladyslav Startsev <vladyslavstartsev@gmail.com> wrote: >> >> Any other ideas on that one? >> >> I'll wait for one more week and make RFC then >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> Hello Benjamin! Thank you for the reply. Can you please explain your point of view a little bit? Things that I don't understand > - bcmath should definitely trigger an error when encountering a malformed string like '17 > .123', silently converting it to zero is indeed the worth thing to do; I don't really understand it, I must be strict, converting to zero will lead to wrong calculations. > - I don't think that there's much value in having it handle exponential notation, you > can use userland libraries such as brick/math for this; Definitely yes, that was my point > - I *really* don't think that it should depend on the current locale, like PHP sometimes > does with numbers; there has been some discussion just a few months ago to actually stop making > float-to-string conversion depend on locale: Sure thing, I was just trying to describe all the cases that we have

« previous php.internals (#105453) next »