PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Numbers » Numbers_Words » Bug #3751

toCurrency incorrectly translates decimal points

Details

Submitted2005-03-09 03:49 UTC
Fromgeekdom at gmail dot com
Assignedmakler
StatusClosed
PackageNumbers_Words
PHP Version5.0.0
OSRedhat 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