src/Number/Rational.php
private function addRational(Rational $r): Rational
    {
        $w = $this->whole;
        $n = $this->numerator;
        $d = $this->denominator;

        $rn = $r->numerator;
        $rd = $r->denominator;
        $rw = $r->whole;

        $w += $rw;

        $lcm = Algebra::lcm($d, $rd);
        $n = $n * intdiv($lcm, $d) + $rn * intdiv($lcm, $rd);
        $d = $lcm;

        return new Rational($w, $n, $d);
    }
private function addRational(Rational $r): Rational
    {
        $w = $this->whole;
        $n = $this->numerator;
        $d = $this->denominator;

        $rn = $r->numerator;
        $rd = $r->denominator;
        $rw = $r->whole;

        $w += $rw;

        $lcm = Algebra::lcm($d, $rd);
        $n = $n * intdiv($lcm, $d) + $rn * intdiv($lcm, $rd);
        $d = $lcm;

        return new Rational($w, $n, $d);
    }
private function addRational ( Rational $ r ) : Rational { $ w = $ this -> whole ; $ n = $ this -> numerator ; $ d = $ this -> denominator ; $ rn = $ r -> numerator ; $ rd = $ r -> denominator ; $ rw = $ r -> whole ; $ w += $ rw ; $ lcm = Algebra :: lcm ( $ d , $ rd ) ; $ n = $ n * intdiv ( $ lcm , $ d ) + $ rn * intdiv ( $ lcm , $ rd ) ; $ d = $ lcm ; return new Rational ( $ w , $ n , $ d ) ; }
Add a rational number

@param Rational $r

@return Rational
Add a rational number