31 if (is_string($operand)) {
32 if (strpos($operand,
'.') !==
false) {
33 $operand = (float) $operand;
35 $operand = (
int) $operand;
45 public function add($left_operand, $right_operand,
int $scale = null)
55 public function sub($left_operand, $right_operand,
int $scale = null)
65 public function mul($left_operand, $right_operand,
int $scale = null)
68 $left_operand = $this->
normalize($left_operand);
69 $right_operand = $this->
normalize($right_operand);
74 $res = $left_operand * $right_operand;
78 if (strpos($e->getMessage(),
'A non-numeric value encountered') !==
false) {
85 return $multiplication;
91 public function div($left_operand, $right_operand,
int $scale = null)
93 if ($right_operand == 0) {
99 $left_operand = $this->
normalize($left_operand);
100 $right_operand = $this->
normalize($right_operand);
105 $res = $left_operand / $right_operand;
109 if (strpos($e->getMessage(),
'A non-numeric value encountered') !==
false) {
122 public function mod($left_operand, $right_operand):
int 124 if ($right_operand == 0) {
134 public function pow($left_operand, $right_operand,
int $scale = null)
144 public function sqrt($operand,
int $scale = null)
154 public function comp($left_operand, $right_operand,
int $scale = null)
156 $left_operand = $this->
normalize($left_operand);
157 $right_operand = $this->
normalize($right_operand);
160 if (is_numeric($scale)) {
161 $left_operand = $this->
applyScale($left_operand, $scale);
162 $right_operand = $this->
applyScale($right_operand, $scale);
165 if ($left_operand == $right_operand) {
169 if ($left_operand > $right_operand) {
mod($left_operand, $right_operand)
comp($left_operand, $right_operand, int $scale=null)
pow($left_operand, $right_operand, int $scale=null)
sqrt($operand, int $scale=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
normalize($number)
This function fixes problems which occur when locale ist set to de_DE for example, because bc* function expecting strings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
mul($left_operand, $right_operand, int $scale=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
applyScale($left_operand, int $scale=null)
add($left_operand, $right_operand, int $scale=null)
transformToNumeric(?string $operand)
sub($left_operand, $right_operand, int $scale=null)
div($left_operand, $right_operand, int $scale=null)