On Sun, Jul 7, 2024 at 8:19 PM Saki Takamachi <s...@sakiot.com> wrote:
> Hi Juliette, > > > Hi Saki, > > > > Just wondering: why `int|string` instead of `float|string` ? > > In my experience, floats are the more pertinent type for which to use > the BCMath extension. > > > > Smile, > > Juliette > > Since floating point numbers always contain a certain amount of error, I > believe that they are not suitable as arguments for BCMath. > > For example, 0.285 becomes 0.284999... in floating point. From the > perspective of arbitrary precision math, there is no universally agreeable > way to properly handle values like this: there will always be people who > want to treat it as 0.285, and people who want to treat it as 0.284999.... > > Therefore, I believe BCMath should not accept floats as arguments. > > Regards, > > Saki I suspected the same thing when I was doing my arbitrary precision library, but I actually have yet to find a test case in all my unit tests where this happens when converting to a string. You can see this here: https://3v4l.org/Ud8Cn Jordan