4 require_once
'Services/Math/classes/class.ilMathBaseAdapter.php';
24 public function add($left_operand, $right_operand, $scale = null)
32 public function sub($left_operand, $right_operand, $scale = null)
40 public function mul($left_operand, $right_operand, $scale = null)
48 public function div($left_operand, $right_operand, $scale = null)
50 if ($right_operand == 0) {
51 require_once
'Services/Math/exceptions/class.ilMathDivisionByZeroException.php';
61 public function mod($left_operand, $right_operand)
63 if ($right_operand == 0) {
64 require_once
'Services/Math/exceptions/class.ilMathDivisionByZeroException.php';
74 public function pow($left_operand, $right_operand, $scale = null)
76 $left_operand = $this->
normalize($left_operand);
77 $right_operand = $this->
normalize($right_operand);
83 $left_operand_dec = $this->
exp2dec($left_operand);
84 $right_operand_dec = $this->
exp2dec($right_operand);
87 if (strpos($right_operand_dec,
'.') ===
false) {
88 return bcpow($left_operand_dec, $right_operand_dec, $scale);
91 return $this->
applyScale(
pow($left_operand, $right_operand), $scale);
97 public function sqrt($operand, $scale = null)
99 return bcsqrt($operand, $scale);
105 public function comp($left_operand, $right_operand, $scale = null)
107 return bccomp($left_operand, $right_operand, $scale);
sqrt($operand, $scale=null)
{Gets the square root of a number.mixed}
mul($left_operand, $right_operand, $scale=null)
{Multiplies two numbers.mixed}
pow($left_operand, $right_operand, $scale=null)
{Raises a number to another.mixed}
Class ilMathBCMathAdapter.
applyScale($number, $scale=null)
This method adapts the behaviour of bcscale()
__construct($scale=0)
ilMathBcMathAdapter constructor.
add($left_operand, $right_operand, $scale=null)
{Adds two numbers.mixed}
normalize($number)
This function fixes problems which occur when locale ist set to de_DE for example, because bc* function expecting strings.
mod($left_operand, $right_operand)
{Gets modulus of two numbers.mixed }
div($left_operand, $right_operand, $scale=null)
{Divides two numbers.mixed }
exp2dec($float_str)
Moved from ilMath...
sub($left_operand, $right_operand, $scale=null)
{Subtracts two numbers.mixed}
comp($left_operand, $right_operand, $scale=null)
{Compares two numbers.mixed}