com.dandymadeproductions.expressionparser.numbers
Class Rational

java.lang.Object
  extended by com.dandymadeproductions.expressionparser.numbers.Rational

public class Rational
extends java.lang.Object

The Rational Data Type implementation class.

Version:
1.7 10/12/2007
Author:
Dana M. Proctor

Field Summary
(package private) static Rational NEG_ONE
           
(package private) static Rational ONE
           
(package private) static Rational TWO
           
(package private) static Rational ZERO
           
 
Constructor Summary
Rational(java.math.BigInteger n, java.math.BigInteger d)
           
Rational(int n)
           
Rational(int n, int d)
           
Rational(java.lang.String rationalString)
           
 
Method Summary
 void add(Rational b)
           
static Rational add(Rational a, Rational b)
           
 void divide(Rational b)
           
static Rational divide(Rational a, Rational b)
           
static java.lang.String getRational(Rational val)
           
static double getRationalDouble(Rational val)
           
static java.lang.String getRationalExact(Rational val)
           
 void multiply(Rational b)
           
static Rational multiply(Rational a, Rational b)
           
 void subtract(Rational b)
           
static Rational subtract(Rational a, Rational b)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

static final Rational ZERO

ONE

static final Rational ONE

TWO

static final Rational TWO

NEG_ONE

static final Rational NEG_ONE
Constructor Detail

Rational

public Rational(java.math.BigInteger n,
                java.math.BigInteger d)

Rational

public Rational(int n)

Rational

public Rational(int n,
                int d)

Rational

public Rational(java.lang.String rationalString)
         throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException
Method Detail

add

public void add(Rational b)

add

public static Rational add(Rational a,
                           Rational b)

subtract

public void subtract(Rational b)

subtract

public static Rational subtract(Rational a,
                                Rational b)

multiply

public void multiply(Rational b)

multiply

public static Rational multiply(Rational a,
                                Rational b)

divide

public void divide(Rational b)

divide

public static Rational divide(Rational a,
                              Rational b)

getRational

public static java.lang.String getRational(Rational val)

toString

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

getRationalExact

public static java.lang.String getRationalExact(Rational val)

getRationalDouble

public static double getRationalDouble(Rational val)