public class Rational extends Number implements Comparable<Rational>
Title: Rational
Description: Object representation of rational numbers.
Note: care should be exercised if Rational objects are used as
keys in a SortedMap or elements in a SortedSet since
Rational's natural ordering is inconsistent with equals.
See Comparable, SortedMap or SortedSet
for more information.
Copyright: Copyright (c) 2009
Company: Clark & Parsia, LLC.
| Constructor and Description |
|---|
Rational(Number numerator,
Number denominator)
Construct a rational number from
|
| Modifier and Type | Method and Description |
|---|---|
static int |
compare(Rational a,
Rational b) |
int |
compareTo(Rational that) |
double |
doubleValue() |
boolean |
equals(Object obj)
Compares this
Rational with the specified
Object for equality. |
float |
floatValue() |
Number |
getDenominator() |
Number |
getNumerator() |
Number |
getQuotient() |
int |
hashCode() |
int |
intValue() |
boolean |
isQuotientExact() |
long |
longValue() |
int |
signum() |
static Rational |
simplify(Rational r) |
String |
toString() |
static Rational |
valueOf(String s) |
byteValue, shortValuepublic Rational(Number numerator, Number denominator)
numerator - An integer valuedenominator - A positive integer valueIllegalArgumentException - if this condition does not hold for the input parameters
OWLRealUtils.acceptable(numerator) && OWLRealUtils.isInteger(numerator) && OWLRealUtils.acceptable(denominator) && OWLRealUtils.isInteger(denominator) && denominator > 0public static Rational valueOf(String s) throws NumberFormatException
NumberFormatExceptionpublic boolean equals(Object obj)
Rational with the specified
Object for equality. Unlike compareTo, this method considers
two Rational objects equal only if they are equal in
numerator and denominator.public int compareTo(Rational that)
compareTo in interface Comparable<Rational>public double doubleValue()
doubleValue in class Numberpublic float floatValue()
floatValue in class Numberpublic Number getDenominator()
public Number getNumerator()
public Number getQuotient()
public boolean isQuotientExact()
public int signum()
Copyright © 2019. All rights reserved.