Class MPInt
java.lang.Object

+MPInt
 public class MPInt
 extends Object
[ Math 220 main page ]
This is a data type for multiprecision integers of arbitrary sign.
Its important data are (1) an array of digits a and (2) a sign s.
Also, for convenience the size n of the subarray
of significant digits is maintained.
Here is a very simple sample program
which multiplies its two arguments.

a


n


sign


MPInt(int)
 Constructs a multiprecision integer from
a standard Java int.

MPInt(int[])
 Constructs a nonnegative multiprecision integer from
an array of digits.

MPInt(int[], int)
 Allows a sign as well.

MPInt(String)
 Constructs an integer from a string of decimal digits.

dividedBy(MPInt)


factorial(int)


minus(MPInt)


modulo(MPInt)


plus(MPInt)
 This is one of the usual arithmetic operations.

times(MPInt)


toString()
 This function is called implicitly when you print a variable of type MPInt.
a
public int a[]
n
public int n
sign
public int sign
MPInt
public MPInt(String s) throws NumberFormatException
 Constructs an integer from a string of decimal digits.
MPInt
public MPInt(int n)
 Constructs a multiprecision integer from
a standard Java int.
MPInt
public MPInt(int a[])
 Constructs a nonnegative multiprecision integer from
an array of digits.
MPInt
public MPInt(int a[],
int s)
 Allows a sign as well.
plus
public MPInt plus(MPInt y)
 This is one of the usual arithmetic operations. They all
can be combined as
the ordinary symbolic operations. They associate to the left.
Thus a.plus(b).times(c) is (a+b)*c, while a.plus(b.times(c)) is (a+(b*c)).
minus
public MPInt minus(MPInt y)
times
public MPInt times(MPInt y)
dividedBy
public MPInt dividedBy(MPInt y) throws ArithmeticException
modulo
public MPInt modulo(MPInt y) throws ArithmeticException
toString
public String toString()
 This function is called implicitly when you print a variable of type MPInt. For
example if a is an MPInt then System.out.println(a)
will print out this string.
 Overrides:
 toString in class Object
factorial
public static MPInt factorial(int n) throws ArithmeticException