src/Chippyash/Math/Type/Calculator/Native.php
public function rationalSub(NI $a, NI $b)
    {
        list($a, $b) = $this->checkRationalTypes($a, $b);
        $d = RationalTypeFactory::create($this->lcm($a->denominator()->get(), $b->denominator()->get()));
        $nn = $this->rationalDiv($this->rationalMul($a->numerator(), $d), $a->denominator())->get();
        $nd = $this->rationalDiv($this->rationalMul($b->numerator(), $d), $b->denominator())->get();
        $n = $this->intSub(new IntType($nn), new IntType($nd));

        return RationalTypeFactory::create($n, $d->numerator());
    }
public function rationalSub(NI $a, NI $b)
    {
        list($a, $b) = $this->checkRationalTypes($a, $b);
        $d = RationalTypeFactory::create($this->lcm($a->denominator()->get(), $b->denominator()->get()));
        $nn = $this->rationalDiv($this->rationalMul($a->numerator(), $d), $a->denominator())->get();
        $nd = $this->rationalDiv($this->rationalMul($b->numerator(), $d), $b->denominator())->get();
        $n = $this->intSub(new IntType($nn), new IntType($nd));

        return RationalTypeFactory::create($n, $d->numerator());
    }
public function rationalSub ( NI $ a , NI $ b ) { list ( $ a , $ b ) = $ this -> checkRationalTypes ( $ a , $ b ) ; $ d = RationalTypeFactory :: create ( $ this -> lcm ( $ a -> denominator ( ) -> get ( ) , $ b -> denominator ( ) -> get ( ) ) ) ; $ nn = $ this -> rationalDiv ( $ this -> rationalMul ( $ a -> numerator ( ) , $ d ) , $ a -> denominator ( ) ) -> get ( ) ; $ nd = $ this -> rationalDiv ( $ this -> rationalMul ( $ b -> numerator ( ) , $ d ) , $ b -> denominator ( ) ) -> get ( ) ; $ n = $ this -> intSub ( new IntType ( $ nn ) , new IntType ( $ nd ) ) ; return RationalTypeFactory :: create ( $ n , $ d -> numerator ( ) ) ; }
Rational number subtraction

@param NI $a first operand
@param NI $b second operand

@return RationalType
Rational number subtraction