コード例 #1
0
ファイル: class.ilMath.php プロジェクト: Walid-Synakene/ilias
 public static function _sub($left_operand, $right_operand, $scale = 50)
 {
     if (function_exists("bcsub")) {
         return bcsub(ilMath::exp2dec($left_operand), ilMath::exp2dec($right_operand), $scale);
     } else {
         $res = $left_operand - $right_operand;
         if (is_numeric($scale)) {
             $res = round($res, $scale);
         }
         return $res;
     }
 }
コード例 #2
0
ファイル: class.ilMath.php プロジェクト: arlendotcn/ilias
 /**
  * @param $fNumber
  * @return string
  * function fixes problem which occur when locale ist set to de_DE for example,
  * because bc* function expecting strings
  */
 private static function bcconv($fNumber)
 {
     $fNumber = ilMath::exp2dec($fNumber);
     $locale_info = localeconv();
     if ($locale_info["decimal_point"] != ".") {
         $sAppend = '';
         $iDecimals = ini_get('precision') - floor(log10(abs($fNumber)));
         if (0 > $iDecimals) {
             $fNumber *= pow(10, $iDecimals);
             $sAppend = str_repeat('0', -$iDecimals);
             $iDecimals = 0;
         }
         return number_format($fNumber, $iDecimals, '.', '') . $sAppend;
     }
     return $fNumber;
 }