Esempio n. 1
0
 public Rational reciprocate() {
   if (zero(num)) throw new ArithmeticException("Divide by zero");
   Rational rv = new Rational(this);
   rv.flip();
   if (negative(den)) {
     rv.num = rv.num.negate();
     rv.den = rv.den.negate();
   }
   return rv;
 }
Esempio n. 2
0
 public Rational divide(Rational b) {
   Rational rv = new Rational(b);
   rv.flip();
   rv.mulEq(this);
   return rv;
 }