function BigDecimal::remainder
Returns the remainder of the division of this number by the given one.
The remainder has a scale of `max($this->scale, $that->scale)`.
Parameters
BigNumber|int|float|string $that The divisor. Must be convertible to a BigDecimal.:
Throws
MathException If the divisor is not a valid decimal number, or is zero.
File
-
vendor/
brick/ math/ src/ BigDecimal.php, line 356
Class
- BigDecimal
- Immutable, arbitrary-precision signed decimal numbers.
Namespace
Brick\MathCode
public function remainder(BigNumber|int|float|string $that) : BigDecimal {
$that = BigDecimal::of($that);
if ($that->isZero()) {
throw DivisionByZeroException::divisionByZero();
}
$p = $this->valueWithMinScale($that->scale);
$q = $that->valueWithMinScale($this->scale);
$remainder = Calculator::get()->divR($p, $q);
$scale = $this->scale > $that->scale ? $this->scale : $that->scale;
return new BigDecimal($remainder, $scale);
}