bigRat
Interface Rational

All Superinterfaces:
java.lang.Comparable<Rational>

public interface Rational
extends java.lang.Comparable<Rational>

Rational numbers of arbitrary precision.

Author:
Claude Anderson and Curt Clifton

Method Summary
Rational abs()
Returns a Rational whose value is the absolute value of this Rational.
Rational add(Rational other)
Returns a Rational whose value is the sum of this and other.
Rational divide(Rational other)
Returns a Rational whose value is the quotient of this and other.
boolean equals(java.lang.Object other)
Compares this rational to the other one
java.lang.String toString()
Returns a String representing this Rational as a reduced fraction numerator/denominator.
Methods inherited from interface java.lang.Comparable
compareTo

Method Detail

abs

Rational abs()
Returns a Rational whose value is the absolute value of this Rational.
Returns:
| this |

add

Rational add(Rational other)
Returns a Rational whose value is the sum of this and other.
Parameters:
other - the other rational number to be added to this one.
Returns:
this + other

divide

Rational divide(Rational other)
Returns a Rational whose value is the quotient of this and other.
Parameters:
other - the rational number by which to divide this one
Returns:
this / other

equals

boolean equals(java.lang.Object other)
Compares this rational to the other one
Overrides:
equals in class java.lang.Object
Parameters:
other - the rational number to which this should be compared
Returns:
true iff this Rational represents the same fraction as other.

toString

java.lang.String toString()
Returns a String representing this Rational as a reduced fraction numerator/denominator.
Overrides:
toString in class java.lang.Object
Returns:
numerator + "/" + denominator