function BigRational::plus
Returns the sum of this number and the given one.
Parameters
BigNumber|int|float|string $that The number to add.:
Throws
MathException If the number is not valid.
File
-
vendor/
brick/ math/ src/ BigRational.php, line 195
Class
- BigRational
- An arbitrarily large rational number.
Namespace
Brick\MathCode
public function plus(BigNumber|int|float|string $that) : BigRational {
$that = BigRational::of($that);
$numerator = $this->numerator
->multipliedBy($that->denominator);
$numerator = $numerator->plus($that->numerator
->multipliedBy($this->denominator));
$denominator = $this->denominator
->multipliedBy($that->denominator);
return new BigRational($numerator, $denominator, false);
}