Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.2
-
Fix Version/s: 1.9.0
-
Component/s: Zend_Currency
-
Labels:None
Description
Zend_Currency::toCurrency() returns wrong number when working with floats lower than 1.0E-5
Code example:
$zendCurrency = new Zend_Currency("USD", "en_US");
$value = 1.0E-4; // 0.0001
echo $zendCurrency->toCurrency($value) ; // outputs $0.00
$value = 1.0E-5; // 0.00001 from -5 it gets wrong
echo $zendCurrency->toCurrency($value) ; // outputs $1.0 - WRONG should be 0.00
The reason to this problem is based on PHP itself.
The scientific value "1.0E-4" is automatically converted to float "0.0001" by php.
But the scientific value "1.0E-5" is not converted.
As Zend_Currency can not handle scientific numbers for now you see the above mentioned result.
You can try this yourself by doing a var_dump on your inputs.