Home » Numbers » Numbers_Words » Bug #3751
toCurrency incorrectly translates decimal points
Details
| Submitted | 2005-03-09 03:49 UTC |
|---|---|
| From | geekdom at gmail dot com |
| Assigned | makler |
| Status | Closed |
| Package | Numbers_Words |
| PHP Version | 5.0.0 |
| OS | Redhat Enterprise Ed |
| Roadmaps | (Not assigned) |
Comments
[2005-03-09 03:49 UTC] geekdom at gmail dot com
Description:
------------
When invoking the function with $0.1 for instance, toCurrency will return "zero dollars, 1 cent" instead of "zero dollars, ten cents".
Since mysql stores decimals by dropping the lagging zeros, this will result in problems.
Reproduce code:
---------------
//Errorneous code (line 118 to 124)
if (strpos($num, '.') === false)
{
$ret = trim($obj->toCurrencyWords($int_curr, $num));
} else {
$currency = explode('.', $num, 2);
$ret = trim($obj->toCurrencyWords($int_curr, $currency[0], $currency[1]));
}
return $ret;
//Patch: Add this line after line 122
if(substr($currency[1],1,1)==null){ $currency[1] = $currency[1]."0";}
Expected result:
----------------
The patch fixes the issue stated