org.lsmp.djep.groupJep.values
Class Rational

java.lang.Object
  extended by java.lang.Number
      extended by org.lsmp.djep.groupJep.values.Rational
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class Rational
extends java.lang.Number
implements java.lang.Comparable

A Rational number with full precision. Represented as quotien of two numbers (always in most reduced form with posative denominator).

Author:
Rich Morris Created on 05-Mar-2004
See Also:
Serialized Form

Constructor Summary
Rational(java.math.BigInteger num)
           
Rational(java.math.BigInteger num, java.math.BigInteger den)
          Rationals will always be represented in most reduced form with a positive denominator.
 
Method Summary
 Rational add(Rational arg)
           
 int compareTo(java.lang.Object arg)
           
 Rational div(Rational arg)
           
 double doubleValue()
           
 float floatValue()
           
 java.math.BigInteger getDenominator()
          * Returns the bottom half of the rational.
 java.math.BigInteger getNumerator()
          Returns the top half of the rational.
 int intValue()
           
 Rational inverse()
           
 long longValue()
           
 Rational mul(Rational arg)
           
 Rational negate()
           
 Rational pow(Rational arg)
           
 Rational sub(Rational arg)
           
 java.lang.String toString()
           
static java.lang.Number valueOf(java.lang.String s)
           
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rational

public Rational(java.math.BigInteger num)

Rational

public Rational(java.math.BigInteger num,
                java.math.BigInteger den)
Rationals will always be represented in most reduced form with a positive denominator.

Method Detail

intValue

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

longValue

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

floatValue

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

doubleValue

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

add

public Rational add(Rational arg)

sub

public Rational sub(Rational arg)

mul

public Rational mul(Rational arg)

div

public Rational div(Rational arg)

pow

public Rational pow(Rational arg)

negate

public Rational negate()

inverse

public Rational inverse()

valueOf

public static java.lang.Number valueOf(java.lang.String s)

getDenominator

public java.math.BigInteger getDenominator()
* Returns the bottom half of the rational.


getNumerator

public java.math.BigInteger getNumerator()
Returns the top half of the rational.


toString

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

compareTo

public int compareTo(java.lang.Object arg)
Specified by:
compareTo in interface java.lang.Comparable


http://www.singularsys.com/jep Copyright © 2007 Singular Systems