Lines Matching defs:Rational

27  * Rational number. </p>
29 public final class Rational extends Number implements Comparable<Rational> {
31 * Constant for the <em>Not-a-Number (NaN)</em> value of the {@code Rational} type.
40 public static final Rational NaN = new Rational(0, 0);
43 * Constant for the positive infinity value of the {@code Rational} type.
48 public static final Rational POSITIVE_INFINITY = new Rational(1, 0);
51 * Constant for the negative infinity value of the {@code Rational} type.
56 public static final Rational NEGATIVE_INFINITY = new Rational(-1, 0);
59 * Constant for the zero value of the {@code Rational} type.
64 public static final Rational ZERO = new Rational(0, 1);
81 * <p>Create a {@code Rational} with a given numerator and denominator.</p>
101 public Rational(int numerator, int denominator) {
210 * <p>Compare this Rational to another object and see if they are equal.</p>
212 * <p>A Rational object can only be equal to another Rational object (comparing against any
215 * <p>A Rational object is considered equal to another Rational object if and only if one of
222 * <p>A reduced form of a Rational is calculated by dividing both the numerator and the
226 * (new Rational(1, 2)).equals(new Rational(1, 2)) == true // trivially true
227 * (new Rational(2, 3)).equals(new Rational(1, 2)) == false // trivially false
228 * (new Rational(1, 2)).equals(new Rational(2, 4)) == true // true after reduction
229 * (new Rational(0, 0)).equals(new Rational(0, 0)) == true // NaN.equals(NaN)
230 * (new Rational(1, 0)).equals(new Rational(5, 0)) == true // both are +infinity
231 * (new Rational(1, 0)).equals(new Rational(-1, 0)) == false // +infinity != -infinity
236 * @return A boolean that determines whether or not the two Rational objects are equal.
240 return obj instanceof Rational && equals((Rational) obj);
243 private boolean equals(Rational other) {
447 * {@code Rational} values. Otherwise, if the objects are not {@link #equals equal}, then
466 public int compareTo(Rational another) {
529 "Rational must be deserialized from a reduced form for zero values");
535 "Rational must be deserialized from a reduced form for infinity values");
539 "Rational must be deserialized from a reduced form for finite values");
545 throw new NumberFormatException("Invalid Rational: \"" + s + "\"");
554 * For any {@code Rational r}: {@code Rational.parseRational(r.toString()).equals(r)}.
559 * "<i>num</i>{@code :}<i>den</i>" {@code => new Rational(num, den);},
564 * Rational.parseRational("3:+6").equals(new Rational(1, 2)) == true
565 * Rational.parseRational("-3/-6").equals(new Rational(1, 2)) == true
566 * Rational.parseRational("4.56") => throws NumberFormatException
576 public static Rational parseRational(String string)
596 return new Rational(Integer.parseInt(string.substring(0, sep_ix)),