diff --git a/library/zendframework/Zend/Locale/Format.php b/library/zendframework/Zend/Locale/Format.php index 1ab1fbf..5fd940f 100644 --- a/library/zendframework/Zend/Locale/Format.php +++ b/library/zendframework/Zend/Locale/Format.php @@ -358,7 +358,7 @@ class Zend_Locale_Format if (strpos($format, '.')) { if (is_numeric($options['precision'])) { - $value = Zend_Locale_Math::round($value, $options['precision']); + $value = Zend_Locale_Math::round($value, $options['precision'], true); } else { if (substr($format, strpos($format, '.') + 1, 3) == '###') { $options['precision'] = null; @@ -370,7 +370,7 @@ class Zend_Locale_Format } } } else { - $value = Zend_Locale_Math::round($value, 0); + $value = Zend_Locale_Math::round($value, 0, true); $options['precision'] = 0; } $value = Zend_Locale_Math::normalize($value); @@ -381,11 +381,11 @@ class Zend_Locale_Format } // get number parts - if (strlen($value) != strlen(Zend_Locale_Math::round($value, 0))) { + if (strlen($value) != strlen(Zend_Locale_Math::round($value, 0, true))) { if ($options['precision'] === null) { - $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1); + $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0, true)) + 1); } else { - $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0)) + 1, $options['precision']); + $precstr = iconv_substr($value, strlen(Zend_Locale_Math::round($value, 0, true)) + 1, $options['precision']); if (iconv_strlen($precstr) < $options['precision']) { $precstr = $precstr . str_pad("0", ($options['precision'] - iconv_strlen($precstr)), "0"); } @@ -403,14 +403,12 @@ class Zend_Locale_Format $options['precision'] = 0; } } - // get fraction and format lengths if (strpos($value, '.') !== false) { $number = substr((string) $value, 0, strpos($value, '.')); } else { $number = $value; } - $prec = call_user_func(Zend_Locale_Math::$sub, $value, $number, $options['precision']); $prec = Zend_Locale_Math::normalize($prec); if (iconv_strpos($prec, '-') !== false) { diff --git a/library/zendframework/Zend/Locale/Math.php b/library/zendframework/Zend/Locale/Math.php index 03658cd..588f403 100644 --- a/library/zendframework/Zend/Locale/Math.php +++ b/library/zendframework/Zend/Locale/Math.php @@ -62,7 +62,7 @@ class Zend_Locale_Math * then try: * Zend_Locale_Math::round('639.795', 2); */ - public static function round($op1, $precision = 0) + public static function round($op1, $precision = 0, $floor = false) { if (self::$_bcmathDisabled) { return self::normalize(round($op1, $precision)); @@ -96,7 +96,7 @@ class Zend_Locale_Math // zero fill digits to the left of the decimal place $op1 = substr($op1, 0, $decPos + $precision) . str_pad('', abs($precision), '0'); } - if ($triggerDigit >= '5') { + if ($triggerDigit >= '5' && !$floor) { if ($roundPos + $decPos == -1) { return str_pad('1', $decPos + 1, '0'); }