37         public static function _add($left_operand, $right_operand, $scale = 50)
 
   43                 if (function_exists(
"bcadd"))
 
   45                         return bcadd($left_operand, $right_operand, $scale);
 
   49                         $res = $left_operand + $right_operand;
 
   50                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
   58         public static function _comp($left_operand, $right_operand, $scale = 50)
 
   64                 if (function_exists(
"bccomp"))
 
   66                         return bccomp($left_operand, $right_operand, $scale);
 
   70                         if (is_numeric($scale)) 
 
   72                                 $left_operand = round($left_operand, $scale);
 
   73                                 $right_operand = round($right_operand, $scale);
 
   75                         if ($left_operand == $right_operand) 
return 0;
 
   76                         if ($left_operand > $right_operand) 
return 1;
 
   84         public static function _div($left_operand, $right_operand, $scale = 50)
 
   90                 if (function_exists(
"bcdiv"))
 
   92                         return bcdiv($left_operand, $right_operand, $scale);
 
   96                         if ($right_operand == 0) 
return NULL;
 
   97                         $res = $left_operand / $right_operand;
 
   98                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  106         public static function _mod($left_operand, $modulus)
 
  111                 if (function_exists(
"bcmod"))
 
  113                         return bcmod($left_operand, $modulus);
 
  117                         return $left_operand % $modulus;
 
  124         public static function _mul($left_operand, $right_operand, $scale = 50)
 
  130                 if (function_exists(
"bcmul"))
 
  132                         return bcmul($left_operand, $right_operand, $scale);
 
  136                         $res = $left_operand * $right_operand;
 
  137                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  145         public static function _pow($left_operand, $right_operand, $scale = 50)
 
  151                 if(function_exists(
"bcpow"))
 
  159                         $is_exponent_decimal_number = strpos($right_operand_dec, 
'.') !== 
false;
 
  162                         if(!$is_exponent_decimal_number)
 
  164                                 return bcpow($left_operand_dec, $right_operand_dec, $scale);
 
  168                 $res = pow($left_operand, $right_operand);
 
  169                 if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  176         public static function _sqrt($operand, $scale = 50)
 
  181                 if (function_exists(
"bcsqrt"))
 
  183                         return bcsqrt($operand, $scale);
 
  187                         $res = sqrt($operand);
 
  188                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  196         public static function _sub($left_operand, $right_operand, $scale = 50)
 
  202                 if (function_exists(
"bcsub"))
 
  204                         return bcsub($left_operand, $right_operand, $scale);
 
  208                         $res = $left_operand - $right_operand;
 
  209                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  222                 $original = $float_str; 
 
  223                 $float_str = (string)((
float)($float_str));
 
  224                 $float_str = str_replace(
",", 
".", $float_str); 
 
  227                 if(($pos = strpos(strtolower($float_str), 
'e')) !== 
false)
 
  230                         $exp = substr($float_str, $pos+1);
 
  231                         $num = substr($float_str, 0, $pos);
 
  234                         if((($num_sign = $num[0]) === 
'+') || ($num_sign === 
'-')) $num = substr($num, 1);
 
  236                         if($num_sign === 
'+') $num_sign = 
'';
 
  239                         if((($exp_sign = $exp[0]) === 
'+') || ($exp_sign === 
'-')) $exp = substr($exp, 1);
 
  240                         else trigger_error(
"Could not convert exponential notation to decimal notation: invalid float string '$float_str'", E_USER_ERROR);
 
  243                         $right_dec_places = (($dec_pos = strpos($num, 
'.')) === 
false) ? 0 : strlen(substr($num, $dec_pos+1));
 
  245                         $left_dec_places = ($dec_pos === 
false) ? strlen($num) : strlen(substr($num, 0, $dec_pos));
 
  248                         if($exp_sign === 
'+') $num_zeros = $exp - $right_dec_places;
 
  249                         else $num_zeros = $exp - $left_dec_places;
 
  252                         $zeros = str_pad(
'', $num_zeros, 
'0');
 
  255                         if($dec_pos !== 
false) $num = str_replace(
'.', 
'', $num);
 
  258                         if($exp_sign === 
'+') 
return $num_sign.$num.$zeros;
 
  260                         else return $num_sign.
'0.'.$zeros.$num;
 
  263                 else return $original;
 
  270                 return $gcd == 1 ? 
true : 
false;
 
  285         public static function _round($value, $precision = 0)
 
  287                 return number_format($value, $precision, 
'.', 
'');
 
  290         public static function _equals($value1, $value2, $scale)
 
  292                 return self::_comp($value1, $value2, $scale) === 0;
 
  304                 $locale_info = localeconv();
 
  305                 if($locale_info[
"decimal_point"] != 
".")
 
  308                         $iDecimals = ini_get(
'precision') - floor(log10(abs($fNumber)));
 
  311                                 $fNumber *= pow(10, $iDecimals);
 
  312                                 $sAppend = str_repeat(
'0', -$iDecimals);
 
  315                         return number_format($fNumber, $iDecimals, 
'.', 
'').$sAppend;