package rebelsky.computation; import java.math.BigDecimal; import rebelsky.io.Pen; /** * A simple test of my various exponentiation methods. * * @author Samuel A. Rebelsky * @version 1.0 of October 2004 */ public class ExpTest { public static void main(String[] args) { Pen pen = new Pen(); if (args.length != 2) { pen.println("Usage: java ExpTest base exponent"); return; } Computer comp = new Computer(); BigDecimal base = new BigDecimal(args[0]); long exponent = Long.parseLong(args[1]); BigDecimal result; comp.reset(); result = comp.expi(base, exponent); pen.println(base + "^" + exponent + " = " + result); pen.println(" Computation took: " + comp.steps() + " multiplications"); comp.reset(); result = comp.expr(base, exponent); pen.println(base + "^" + exponent + " = " + result); pen.println(" Computation took: " + comp.steps() + " multiplications"); } // main(String[]) } // class ExpTest