Exemplo n.º 1
0
        $sum->reduce();
        $sum->show();
    }
    public static function multiply(Fraction $a, Fraction $b)
    {
        $num = $a->numerator * $b->numerator;
        $den = $a->denominator * $b->denominator;
        $sum = new Fraction($num, $den);
        $sum->reduce();
        $sum->show();
    }
    public static function divide(Fraction $a, Fraction $b)
    {
        $num = $a->numerator * $b->denominator;
        $den = $a->denominator * $b->numerator;
        $sum = new Fraction($num, $den);
        $sum->reduce();
        $sum->show();
    }
}
$a = new Fraction(2, 4);
$b = new Fraction(3, 5);
Fraction::sum($a, $b);
Fraction::subtract($a, $b);
Fraction::multiply($a, $b);
Fraction::divide($a, $b);
$c = new Fraction(46463132, 49649492);
$c->show();
$c->reduce();
$c->show();
$c->decimal_fraction();