37         public static function _add($left_operand, $right_operand, $scale = 50)
 
   39                 if (function_exists(
"bcadd"))
 
   45                         $res = $left_operand + $right_operand;
 
   46                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
   54         public static function _comp($left_operand, $right_operand, $scale = 50)
 
   56                 if (function_exists(
"bccomp"))
 
   62                         if (is_numeric($scale)) 
 
   64                                 $left_operand = round($left_operand, $scale);
 
   65                                 $right_operand = round($right_operand, $scale);
 
   67                         if ($left_operand == $right_operand) 
return 0;
 
   68                         if ($left_operand > $right_operand) 
return 1;
 
   76         public static function _div($left_operand, $right_operand, $scale = 50)
 
   78                 if (function_exists(
"bcdiv"))
 
   84                         if ($right_operand == 0) 
return NULL;
 
   85                         $res = $left_operand / $right_operand;
 
   86                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
   94         public static function _mod($left_operand, $modulus)
 
   96                 if (function_exists(
"bcmod"))
 
  102                         return $left_operand % $right_operand;
 
  109         public static function _mul($left_operand, $right_operand, $scale = 50)
 
  111                 if (function_exists(
"bcmul"))
 
  117                         $res = $left_operand * $right_operand;
 
  118                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  126         public static function _pow($left_operand, $right_operand, $scale = 50)
 
  128                 if(function_exists(
"bcpow"))
 
  136                         $is_exponent_decimal_number = strpos($right_operand_dec, 
'.') !== 
false;
 
  137                         if(!$is_exponent_decimal_number || $scale > 14)
 
  139                                 return bcpow($left_operand_dec, $right_operand_dec, $scale);
 
  145                 $res = pow($left_operand, $right_operand);
 
  146                 if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  153         public static function _sqrt($operand, $scale = 50)
 
  155                 if (function_exists(
"bcsqrt"))
 
  161                         $res = sqrt($operand);
 
  162                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  170         public static function _sub($left_operand, $right_operand, $scale = 50)
 
  172                 if (function_exists(
"bcsub"))
 
  178                         $res = $left_operand - $right_operand;
 
  179                         if (is_numeric($scale)) 
$res = round(
$res, $scale);
 
  192                 $original = $float_str; 
 
  193                 $float_str = (string)((
float)($float_str));
 
  194                 $float_str = str_replace(
",", 
".", $float_str); 
 
  197                 if(($pos = strpos(strtolower($float_str), 
'e')) !== 
false)
 
  200                         $exp = substr($float_str, $pos+1);
 
  201                         $num = substr($float_str, 0, $pos);
 
  204                         if((($num_sign = $num[0]) === 
'+') || ($num_sign === 
'-')) $num = substr($num, 1);
 
  206                         if($num_sign === 
'+') $num_sign = 
'';
 
  209                         if((($exp_sign = $exp[0]) === 
'+') || ($exp_sign === 
'-')) $exp = substr($exp, 1);
 
  210                         else trigger_error(
"Could not convert exponential notation to decimal notation: invalid float string '$float_str'", E_USER_ERROR);
 
  213                         $right_dec_places = (($dec_pos = strpos($num, 
'.')) === 
false) ? 0 : strlen(substr($num, $dec_pos+1));
 
  215                         $left_dec_places = ($dec_pos === 
false) ? strlen($num) : strlen(substr($num, 0, $dec_pos));
 
  218                         if($exp_sign === 
'+') $num_zeros = $exp - $right_dec_places;
 
  219                         else $num_zeros = $exp - $left_dec_places;
 
  222                         $zeros = str_pad(
'', $num_zeros, 
'0');
 
  225                         if($dec_pos !== 
false) $num = str_replace(
'.', 
'', $num);
 
  228                         if($exp_sign === 
'+') 
return $num_sign.$num.$zeros;
 
  230                         else return $num_sign.
'0.'.$zeros.$num;
 
  233                 else return $original;
 
  240                 return $gcd == 1 ? 
true : 
false;