function BigDecimal::multipliedBy
Returns the product of this number and the given one.
The result has a scale of `$this->scale + $that->scale`.
Parameters
BigNumber|int|float|string $that The multiplier. Must be convertible to a BigDecimal.:
Throws
MathException If the multiplier is not a valid number, or is not convertible to a BigDecimal.
File
-
vendor/
brick/ math/ src/ BigDecimal.php, line 199
Class
- BigDecimal
- Immutable, arbitrary-precision signed decimal numbers.
Namespace
Brick\MathCode
public function multipliedBy(BigNumber|int|float|string $that) : BigDecimal {
$that = BigDecimal::of($that);
if ($that->value === '1' && $that->scale === 0) {
return $this;
}
if ($this->value === '1' && $this->scale === 0) {
return $that;
}
$value = Calculator::get()->mul($this->value, $that->value);
$scale = $this->scale + $that->scale;
return new BigDecimal($value, $scale);
}