|
@@ 88-97 (lines=10) @@
|
| 85 |
|
* @param int $scale
|
| 86 |
|
* @return string
|
| 87 |
|
*/
|
| 88 |
|
public static function mul($leftOperand, $rightOperand, $scale = null)
|
| 89 |
|
{
|
| 90 |
|
$leftOperand = self::convertScientificNotationToString($leftOperand);
|
| 91 |
|
$rightOperand = self::convertScientificNotationToString($rightOperand);
|
| 92 |
|
|
| 93 |
|
if (null === $scale) {
|
| 94 |
|
return bcmul($leftOperand, $rightOperand);
|
| 95 |
|
}
|
| 96 |
|
|
| 97 |
|
return bcmul($leftOperand, $rightOperand, $scale);
|
| 98 |
|
}
|
| 99 |
|
|
| 100 |
|
/**
|
|
@@ 106-116 (lines=11) @@
|
| 103 |
|
* @param int $scale
|
| 104 |
|
* @return string
|
| 105 |
|
*/
|
| 106 |
|
public static function pow($leftOperand, $rightOperand, $scale = null)
|
| 107 |
|
{
|
| 108 |
|
$leftOperand = self::convertScientificNotationToString($leftOperand);
|
| 109 |
|
$rightOperand = self::convertScientificNotationToString($rightOperand);
|
| 110 |
|
|
| 111 |
|
if (null === $scale) {
|
| 112 |
|
return bcpow($leftOperand, $rightOperand);
|
| 113 |
|
}
|
| 114 |
|
|
| 115 |
|
return bcpow($leftOperand, $rightOperand, $scale);
|
| 116 |
|
}
|
| 117 |
|
|
| 118 |
|
/**
|
| 119 |
|
* @param string $leftOperand
|
|
@@ 124-133 (lines=10) @@
|
| 121 |
|
* @param int $scale
|
| 122 |
|
* @return string
|
| 123 |
|
*/
|
| 124 |
|
public static function div($leftOperand, $rightOperand, $scale = null)
|
| 125 |
|
{
|
| 126 |
|
$leftOperand = self::convertScientificNotationToString($leftOperand);
|
| 127 |
|
$rightOperand = self::convertScientificNotationToString($rightOperand);
|
| 128 |
|
|
| 129 |
|
if (null === $scale) {
|
| 130 |
|
return bcdiv($leftOperand, $rightOperand);
|
| 131 |
|
}
|
| 132 |
|
|
| 133 |
|
return bcdiv($leftOperand, $rightOperand, $scale);
|
| 134 |
|
}
|
| 135 |
|
|
| 136 |
|
/**
|
|
@@ 174-184 (lines=11) @@
|
| 171 |
|
* @param int $scale
|
| 172 |
|
* @return string
|
| 173 |
|
*/
|
| 174 |
|
public static function sub($leftOperand, $rightOperand, $scale = null)
|
| 175 |
|
{
|
| 176 |
|
$leftOperand = self::convertScientificNotationToString($leftOperand);
|
| 177 |
|
$rightOperand = self::convertScientificNotationToString($rightOperand);
|
| 178 |
|
|
| 179 |
|
if (null === $scale) {
|
| 180 |
|
return bcsub($leftOperand, $rightOperand);
|
| 181 |
|
}
|
| 182 |
|
|
| 183 |
|
return bcsub($leftOperand, $rightOperand, $scale);
|
| 184 |
|
}
|
| 185 |
|
|
| 186 |
|
/**
|
| 187 |
|
* @param string $leftOperand
|
|
@@ 192-202 (lines=11) @@
|
| 189 |
|
* @param int $scale
|
| 190 |
|
* @return string
|
| 191 |
|
*/
|
| 192 |
|
public static function add($leftOperand, $rightOperand, $scale = null)
|
| 193 |
|
{
|
| 194 |
|
$leftOperand = self::convertScientificNotationToString($leftOperand);
|
| 195 |
|
$rightOperand = self::convertScientificNotationToString($rightOperand);
|
| 196 |
|
|
| 197 |
|
if (null === $scale) {
|
| 198 |
|
return bcadd($leftOperand, $rightOperand);
|
| 199 |
|
}
|
| 200 |
|
|
| 201 |
|
return bcadd($leftOperand, $rightOperand, $scale);
|
| 202 |
|
}
|
| 203 |
|
|
| 204 |
|
/**
|
| 205 |
|
* @param int|string $number
|
|
@@ 463-473 (lines=11) @@
|
| 460 |
|
* @param int $scale
|
| 461 |
|
* @return string
|
| 462 |
|
*/
|
| 463 |
|
public static function powMod($leftOperand, $rightOperand, $modulus, $scale = null)
|
| 464 |
|
{
|
| 465 |
|
$leftOperand = self::convertScientificNotationToString($leftOperand);
|
| 466 |
|
$rightOperand = self::convertScientificNotationToString($rightOperand);
|
| 467 |
|
|
| 468 |
|
if (null === $scale) {
|
| 469 |
|
return bcpowmod($leftOperand, $rightOperand, $modulus);
|
| 470 |
|
}
|
| 471 |
|
|
| 472 |
|
return bcpowmod($leftOperand, $rightOperand, $modulus, $scale);
|
| 473 |
|
}
|
| 474 |
|
}
|
| 475 |
|
|