BCMath and floats

From: Date: Mon, 11 Sep 2017 15:36:45 +0000
Subject: BCMath and floats
Groups: php.internals 
Request: Send a blank email to internals+get-100521@lists.php.net to get a copy of this message
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

« previous php.internals (#100521) next »