org.semanticweb.HermiT.datatypes.owlreal
Class BigRational
java.lang.Object
java.lang.Number
org.semanticweb.HermiT.datatypes.owlreal.BigRational
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<BigRational>
public class BigRational
- extends java.lang.Number
- implements java.lang.Comparable<BigRational>
Represents rational numbers. The denominator is always a positive integer.
The rational is usually reduced -- that is, gcd(m_numerator,m_denominator)==1.
Furthermore, m_denominator is usually greated than one.
These restrictions are used in .equals(). Sometimes, however,
rationals are created that do not satisfy this condition. In such cases,
.equals() and .hasCode() may return incorrect values. This hack has been introduced
to enable efficient comparison of rationals with other kinds of numbers in the
Numbers class. The compareTo() method always returns correct values.
- See Also:
- Serialized Form
|
Constructor Summary |
BigRational(java.math.BigInteger numerator,
java.math.BigInteger denominator)
|
| Methods inherited from class java.lang.Number |
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
BigRational
public BigRational(java.math.BigInteger numerator,
java.math.BigInteger denominator)
getNumerator
public java.math.BigInteger getNumerator()
getDenominator
public java.math.BigInteger getDenominator()
isFinitelyRepresentable
public boolean isFinitelyRepresentable()
compareTo
public int compareTo(BigRational that)
- Specified by:
compareTo in interface java.lang.Comparable<BigRational>
equals
public boolean equals(java.lang.Object that)
- Overrides:
equals in class java.lang.Object
hashCode
public int hashCode()
- Overrides:
hashCode in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
doubleValue
public double doubleValue()
- Specified by:
doubleValue in class java.lang.Number
floatValue
public float floatValue()
- Specified by:
floatValue in class java.lang.Number
intValue
public int intValue()
- Specified by:
intValue in class java.lang.Number
longValue
public long longValue()
- Specified by:
longValue in class java.lang.Number