JExigo - Java Fixed Point Arithmetic


Get jExigo - Java Fixed Decimal Arithmetic at SourceForge.net. Fast, secure and Free Open Source software downloads

Features

Simple math function for fixed point decimal numbers.
Add
Subtract
Multiply
Divide

Other functions too

Examples

FixedDecimalNumber fda = new FixedDecimalNumber("1.1"); System.out.print("Adding: " +fda.get()); FixedDecimalNumber fdb = new FixedDecimalNumber("1.01"); System.out.print(" + " + fdb.toString() + " = "); // notice get and toString are the same fda = FixedDecimalArithmetic.add(fda, fdb); System.out.println(fda.get()); System.out.print("Subtractring: " +fda.get()); System.out.print(" - " + fdb.toString() + " = "); fda = FixedDecimalArithmetic.subtract(fda, fdb); System.out.println(fda); // notice how precision is not lost System.out.print("Multiplying: " +fda.get()); System.out.print(" * " + fdb.toString() + " = "); fda = FixedDecimalArithmetic.multiply(fda, fdb); System.out.println(fda); // notice how precision is extended System.out.print("Dividing: " +fda.get()); System.out.print(" / " + fdb.toString() + " = "); fda = FixedDecimalArithmetic.divide(fda, fdb); System.out.println(fda); // notice how precision is extended fda.toDecimalPlaces(2); System.out.println("truncate to 2 decimal places "+fda); fda.toDecimalPlaces(3); System.out.println("show as 3 decimal places "+fda); fdb = fda.copy(); System.out.println("fda == fdb is " + (fda.compare(fdb)==0)); fdb.toDecimalPlaces(14); System.out.println(fda + " == " + fdb + " is " + (fda.compare(fdb)==0));

Publish or Perish

Joe McVerry

American Coders, Ltd