Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5.1, 1.5.2
-
Fix Version/s: 1.8.0
-
Component/s: Zend_Locale
-
Labels:None
Description
Zend_Locale_Format seems to not like float numbers starting with 9.
This is because of the following code in Zend/Locale/Format.php (around line 386 in 1.5.2):
{{
if (strlen($value) != strlen(Zend_Locale_Math::round($value, 0))) {
if ($options['precision'] === null) {
$precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1);
} else {
}}
Unfortunately round(9.72) == 10 which accounts for 2 characters instead of only one, hence the precstr length is only 1 character instead of the two it should have, and the final returned number is missing one charater.
A possible fix would be to not round, but use floor to get the decimal part size.
This would not work as floor takes in account the locale, Zend_Locale_Math does not as it's locale independent.
So your solution would not work for other locales than english or the one near to english.
Also your solution would only work with positive numbers.
So your attached patch does not solve the problem.