Hi everybody!

All BCMath functions expects strings as operands (in the strict sense;
do not confuse with arguments).  This of course can result in unexpected
behavior if floats are passed, namely:

 * floats may be converted to a string in scientific notation
 * floats may be converted with a decimal separator which is not a point

Both result in BCMath treating such strings as '0'.  Over the years
there have been at least six bug reports regarding this issue: #10116,
#42871, #47633, #55160, #66745, #66959.  The last one has been
reclassified as feature request, and I would like to address it.

I already have proposed to introduce bcinit() which would take a string,
int or float, and return a properly formatted string with the given or
default scale, see <https://github.com/php/php-src/pull/2746>.  Nikita
suggested to accept the arguments allowed by `bcinit()` for all
functions in the first place.  This would, however, raise the question
which scale should be applied to floats.

Before proceeding to an RFC (if necessary at all), I'm looking forward
to hear your thoughts regarding this topic.

-- 
Christoph M. Becker

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to