ZF-5374: bcmath doesn't handle numbers in exponential notation


Try this :

$unit = new Zend_Measure_Pressure(1, Zend_Measure_Pressure::KILOBAR);
echo $unit->toString();

It should display 100000000.0000000000000000000000000 N/m², but it displays 0.

I think it's because bcmath doesn't handle numbers in exponential notation. If you look in Zend_Measure_Pressure, you can see that '1.0e+8' is set for KILOBAR factor. bcmath doesn't recognize the 'e+8', so it multiplies the value by 0. Obviously, it's like this everywhere.

One workaround is to remove the quote and use a float, or better write the factors expanded : 100000000 instead of 1.0e+8.


bcmath is a php extension and not related to ZF. This is not a issue of ZF.

If you apply my patch of Zend_Locale_Math::normalize (see […]) and use it in Zend_Measure_Abstract::setType, the problem is resolved (unless you don't use bcmath, because I use bcmul and bcpow).

$value = call_user_func(Zend_Locale_Math::$mul, $value, Zend_Locale_Math::normalize($this->_units[$this->getType()][0]), 25);

Issues of php itself of it's extensions can't be solved by ZF. Therefor this issue will be closed.