Exemple #1
0
 /**
  * Returns the product of this number and the given one.
  *
  * The result has a scale of `$this->scale + $that->scale`.
  *
  * @param \Arki\Math\Number|int|float|string $that The multiplier. Must be convertible to a BigDecimal.
  *
  * @return BigDecimal The result.
  *
  * @throws \ArithmeticError If the multiplier is not a valid number, or is not convertible to a BigDecimal.
  */
 public function multipliedBy($that)
 {
     $that = self::of($that);
     if ($that->intVal->isEqualTo('1') && $that->scale === 0) {
         return $this;
     }
     $value = $this->intVal->multipliedBy($that->intVal);
     $scale = $this->scale + $that->scale;
     return new self($value, $scale);
 }