com.clarkparsia.pellet.datatypes.types.real
Class Rational

java.lang.Object
  extended by java.lang.Number
      extended by com.clarkparsia.pellet.datatypes.types.real.Rational
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Rational>

public class Rational
extends java.lang.Number
implements java.lang.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.

Author:
Mike Smith
See Also:
Serialized Form

Constructor Summary
Rational(java.lang.Number numerator, java.lang.Number denominator)
          Construct a rational number from
 
Method Summary
static int compare(Rational a, Rational b)
           
 int compareTo(Rational that)
           
 double doubleValue()
           
 boolean equals(java.lang.Object obj)
          Compares this Rational with the specified Object for equality.
 float floatValue()
           
 java.lang.Number getDenominator()
           
 java.lang.Number getNumerator()
           
 java.lang.Number getQuotient()
           
 int hashCode()
           
 int intValue()
           
 boolean isQuotientExact()
           
 long longValue()
           
 int signum()
           
static Rational simplify(Rational r)
           
 java.lang.String toString()
           
static Rational valueOf(java.lang.String s)
           
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rational

public Rational(java.lang.Number numerator,
                java.lang.Number denominator)
Construct a rational number from

Parameters:
numerator - An integer value
denominator - A positive integer value
Throws:
java.lang.IllegalArgumentException - if this condition does not hold for the input parameters OWLRealUtils.acceptable(numerator) && OWLRealUtils.isInteger(numerator) && OWLRealUtils.acceptable(denominator) && OWLRealUtils.isInteger(denominator) && denominator > 0
Method Detail

compare

public static int compare(Rational a,
                          Rational b)

valueOf

public static Rational valueOf(java.lang.String s)
                        throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException

simplify

public static Rational simplify(Rational r)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compares this 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.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to which this Rational is to be compared
Returns:
true> if and only if the specified Object is a Rational whose numerator and denominator are equal to this Rational's.

compareTo

public int compareTo(Rational that)
Specified by:
compareTo in interface java.lang.Comparable<Rational>

doubleValue

public double doubleValue()
Specified by:
doubleValue in class java.lang.Number

floatValue

public float floatValue()
Specified by:
floatValue in class java.lang.Number

getDenominator

public java.lang.Number getDenominator()

getNumerator

public java.lang.Number getNumerator()

getQuotient

public java.lang.Number getQuotient()

intValue

public int intValue()
Specified by:
intValue in class java.lang.Number

isQuotientExact

public boolean isQuotientExact()

longValue

public long longValue()
Specified by:
longValue in class java.lang.Number

signum

public int signum()


Copyright © 2004 Evren Sirin. All Rights Reserved.