org.semanticweb.HermiT.datatypes.owlreal
Class BigRational

java.lang.Object
  extended by java.lang.Number
      extended by org.semanticweb.HermiT.datatypes.owlreal.BigRational
All Implemented Interfaces:
Serializable, Comparable<BigRational>

public class BigRational
extends Number
implements 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(BigInteger numerator, BigInteger denominator)
           
 
Method Summary
 int compareTo(BigRational that)
           
 double doubleValue()
           
 boolean equals(Object that)
           
 float floatValue()
           
 BigInteger getDenominator()
           
 BigInteger getNumerator()
           
 int hashCode()
           
 int intValue()
           
 boolean isFinitelyRepresentable()
           
 long longValue()
           
 String toString()
           
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BigRational

public BigRational(BigInteger numerator,
                   BigInteger denominator)
Method Detail

getNumerator

public BigInteger getNumerator()

getDenominator

public BigInteger getDenominator()

isFinitelyRepresentable

public boolean isFinitelyRepresentable()

compareTo

public int compareTo(BigRational that)
Specified by:
compareTo in interface Comparable<BigRational>

equals

public boolean equals(Object that)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

doubleValue

public double doubleValue()
Specified by:
doubleValue in class Number

floatValue

public float floatValue()
Specified by:
floatValue in class Number

intValue

public int intValue()
Specified by:
intValue in class Number

longValue

public long longValue()
Specified by:
longValue in class Number


Copyright © 2012. All Rights Reserved.