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;
elseif(isset( $params[ 'redirect_parent']))
static Sub($op1, $op2, $scale=null)
static floatalize($value)
static Add($op1, $op2, $scale=null)
static Sub($op1, $op2, $scale=null)
static round($op1, $precision=0)
static Add($op1, $op2, $scale=null)