40 public static $add = array(
'Zend_Locale_Math',
'Add');
41 public static $sub = array(
'Zend_Locale_Math',
'Sub');
42 public static $pow = array(
'Zend_Locale_Math',
'Pow');
43 public static $mul = array(
'Zend_Locale_Math',
'Mul');
44 public static $div = array(
'Zend_Locale_Math',
'Div');
45 public static $comp = array(
'Zend_Locale_Math',
'Comp');
46 public static $sqrt = array(
'Zend_Locale_Math',
'Sqrt');
47 public static $mod = array(
'Zend_Locale_Math',
'Mod');
65 public static function round($op1, $precision = 0)
67 if (self::$_bcmathDisabled) {
68 $op1 =
round($op1, $precision);
69 if (strpos((
string) $op1,
'E') ===
false) {
74 if (strpos($op1,
'E') !==
false) {
78 $op1 = trim(self::normalize($op1));
79 $length = strlen($op1);
80 if (($decPos = strpos($op1,
'.')) ===
false) {
85 if ($precision < 0 && abs($precision) > $decPos) {
89 $digitsBeforeDot = $length - ($decPos + 1);
90 if ($precision >= ($length - ($decPos + 1))) {
94 if ($precision === 0) {
97 }
elseif ($precision > 0) {
98 $triggerPos = $precision + 1;
99 $roundPos = $precision;
101 $triggerPos = $precision;
102 $roundPos = $precision -1;
105 $triggerDigit = $op1[$triggerPos + $decPos];
106 if ($precision < 0) {
108 $op1 = substr($op1, 0, $decPos + $precision) . str_pad(
'', abs($precision),
'0');
111 if ($triggerDigit >=
'5') {
112 if ($roundPos + $decPos == -1) {
113 return str_pad(
'1', $decPos + 1,
'0');
116 $roundUp = str_pad(
'', $length,
'0');
117 $roundUp[$decPos] =
'.';
118 $roundUp[$roundPos + $decPos] =
'1';
121 if (self::$_bcmathDisabled) {
124 return self::Add($op1, $roundUp, $precision);
126 if (self::$_bcmathDisabled) {
129 return self::Sub($op1, $roundUp, $precision);
131 }
elseif ($precision >= 0) {
132 return substr($op1, 0, $decPos + ($precision ? $precision + 1: 0));
135 return (
string) $op1;
147 if (strpos(
$value,
'E') ===
false) {
152 if (strpos(
$number,
'.') !==
false) {
156 $post += abs((
int) $mantis);
176 $convert = localeconv();
177 $value = str_replace($convert[
'thousands_sep'],
"",(
string)
$value);
178 $value = str_replace($convert[
'positive_sign'],
"",
$value);
179 $value = str_replace($convert[
'decimal_point'],
".",
$value);
180 if (!empty($convert[
'negative_sign']) and (strpos(
$value, $convert[
'negative_sign']))) {
181 $value = str_replace($convert[
'negative_sign'],
"",
$value);
197 $convert = localeconv();
198 $value = str_replace(
".", $convert[
'decimal_point'], (
string)
$value);
199 if (!empty($convert[
'negative_sign']) and (strpos(
$value,
"-"))) {
200 $value = str_replace(
"-", $convert[
'negative_sign'],
$value);
215 if (!extension_loaded(
'bcmath')) {
219 $split = explode(
'e',
$value);
220 if (count($split) == 1) {
221 $split = explode(
'E',
$value);
224 if (count($split) > 1) {
244 return bcadd($op1, $op2,
$scale);
259 return bcsub($op1, $op2,
$scale);
274 return bcpow($op1, $op2,
$scale);
289 return bcmul($op1, $op2,
$scale);
304 return bcdiv($op1, $op2,
$scale);
317 return bcsqrt($op1,
$scale);
327 public static function Mod($op1, $op2)
331 return bcmod($op1, $op2);
346 return bccomp($op1, $op2,
$scale);
350 if (!extension_loaded(
'bcmath')
351 || (defined(
'TESTS_ZEND_LOCALE_BCMATH_ENABLED') && !TESTS_ZEND_LOCALE_BCMATH_ENABLED)
353 #require_once 'Zend/Locale/Math/PhpMath.php';
static Sqrt($op1, $scale=null)
elseif(isset( $params[ 'redirect_parent']))
static Sub($op1, $op2, $scale=null)
static floatalize($value)
static exponent($value, $scale=null)
static Div($op1, $op2, $scale=null)
static Comp($op1, $op2, $scale=null)
static Add($op1, $op2, $scale=null)
static isBcmathDisabled()
static Mul($op1, $op2, $scale=null)
static Sub($op1, $op2, $scale=null)
static Pow($op1, $op2, $scale=null)
static round($op1, $precision=0)
static Add($op1, $op2, $scale=null)