//***************************************************************************** // // Beenish Chaudry, Geetika Tewari, Elif Tosun and // Ileana Streinu // // Summer 1999, Fall 1999, Spring 2000 // //***************************************************************************** // // RationalBig.java // //***************************************************************************** import java.awt.*; import java.awt.event.*; import java.lang.*; import java.io.*; import java.util.*; import java.math.*; public class RationalBig { BigInteger d, n, // deonominator, numerator b1; // constant BigInteger, for various initializations final String str = "1"; // constant as required by BigInteger //************************ // // Constructor // //************************ public RationalBig (BigInteger nenum, BigInteger denum) { d = n = b1 = new BigInteger (str); n = nenum; d = denum; } // ends const. //************************ // // AddR // //************************ public RationalBig AddR (RationalBig a) { RationalBig b = new RationalBig(b1, b1); b.n = (this.n.multiply(a.d)).add(this.d.multiply(a.n)); b.d = (this.d.multiply(a.d)); return b; } //************************ // // SubR // //************************ public RationalBig SubR (RationalBig a) { RationalBig b = new RationalBig(b1, b1); b.n = (this.n.multiply(a.d)).subtract(this.d.multiply(a.n)); //this - a b.d = (this.d.multiply(a.d)); return b; } //************************ // // MulR // //************************ public RationalBig MulR (RationalBig a) { RationalBig b = new RationalBig(b1, b1); b.n = (this.n.multiply(a.n)); b.d = (this.d.multiply(a.d)); return b; } //************************ // // DivR // //************************ public RationalBig DivR (RationalBig a) { RationalBig b = new RationalBig(b1, b1); b.n = (this.n.multiply(a.d)); b.d = (this.d.multiply(a.n)); return b; } //************************ // // RelToAbs // //************************ // temporary fix - work on it later. Ileana, Feb 22, 2000 public // BigInteger void RelToAbs(int trans, Rational unitL, int sig) { /* String str = " "; //to apply function valueOf RationalBig BigunitL = new RationalBig (str.valueOf(unitL.n), str.valueOf(unitL.d)); RationalBig tmp = this.MulR(BigunitL); BigInteger a = tmp.n.divide(tmp.d); //throws arithmetic exception a = a.multiply(str.value0f(sig)).add(str.valueOf(trans)); return(a); */ } // end RelToAbs } // ends class