org.lsmp.djep.groupJep.values
Class Rational

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

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()

longValue

public long longValue()

floatValue

public float floatValue()

doubleValue

public double doubleValue()

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()

compareTo

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


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