0) { $result = round($result, $op3); } else { if ($result > 0) { $result = floor($result); } else { $result = ceil($result); } } if ($op3 > 0) { if ((string) $result == "0") { $result = "0."; } if (strlen($result) < ($op3 + 2)) { $result = str_pad($result, ($op3 + 2), "0", STR_PAD_RIGHT); } } return $result; } function Zend_Locale_Math_Pow($base, $exp) { $result = pow($base, $exp); if ($result === false) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("power overflow: $op1 ^ $op2", $op1, $op2, $result); } return $result; } function Zend_Locale_Math_Mul($op1, $op2) { if (empty($op1)) { $op1 = 0; } $result = $op1 * $op2; if ((string)($result / $op2) != (string)$op1) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("multiplication overflow: $op1 * $op2 != $result", $op1, $op2, $result); } return $result; } function Zend_Locale_Math_Div($op1, $op2) { $result = $op1 / $op2; if (empty($op2)) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("can not divide by zero"); } if (empty($op1)) { $op1 = 0; } if ((string)($result * $op2) != (string)$op1) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("division overflow: $op1 / $op2 != $result", $op1, $op2, $result); } return $result; } function Zend_Locale_Math_Comp($op1, $op2) { if (empty($op1)) { $op1 = 0; } // @todo: this unecessarily breaks for $op1 == large positive #, $op2 = large negative number $result = $op1 - $op2; if ((string)($result + $op2) != (string)$op1) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("compare overflow: comp($op1, $op2)", $op1, $op2, $result); } return $result; } function Zend_Locale_Math_Sqrt($op1) { if (empty($op1)) { $op1 = 0; } $result = sqrt($op1); if (is_string($op1) && (string)($result * $result) != (string)$op1) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("sqrt operand overflow: $op1", $op1, null, $result); } return $result; } function Zend_Locale_Math_Mod($op1, $op2) { if (empty($op1)) { $op1 = 0; } $result = $op1 / $op2; if (empty($op2)) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("can not modulo by zero: $op1 % $op2", $op1, $op2, $result); } if ((string)($result * $op2) != (string)$op1) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("modulo overflow: $op1 % $op2 (result=$result)", $op1, $op2, $result); } $result = $op1 % $op2; return $result; } function Zend_Locale_Math_Scale($op1) { if ($op1 > 9) { /** * @see Zend_Locale_Math_Exception */ require_once 'Zend/Locale/Math/Exception.php'; throw new Zend_Locale_Math_Exception("can not scale to precision $op1", $op1, null, $result); } } Zend_Locale_Math_PhpMath::disable(); // disable use of bcmath functions ?>