ZF-5374: bcmath doesn't handle numbers in exponential notation
Description
Try this :
$unit = new Zend_Measure_Pressure(1, Zend_Measure_Pressure::KILOBAR);
$unit->setType(Zend_Measure_Pressure::STANDARD);
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.
Comments
Posted by Thomas Weidner (thomas) on 2008-12-29T11:43:56.000+0000
bcmath is a php extension and not related to ZF. This is not a issue of ZF.
Posted by Maxence Delannoy (mdelanno) on 2008-12-30T00:27:55.000+0000
If you apply my patch of Zend_Locale_Math::normalize (see [http://framework.zend.com/issues/browse/…]) and use it in Zend_Measure_Abstract::setType, the problem is resolved (unless you don't use bcmath, because I use bcmul and bcpow).
Posted by Thomas Weidner (thomas) on 2009-01-03T05:33:03.000+0000
Issues of php itself of it's extensions can't be solved by ZF. Therefor this issue will be closed.