Class Intzilla

java.lang.Object
  extended by Intzilla

public class Intzilla
extends java.lang.Object

This class represents arbitrarily large signed integers, up to Integer.MAXINT digits. Basic arithmetic operations are implemented, such as addition (plus), subtraction (minus), multiplication (times), and integer division (div and mod), as well as predicates for equality and comparisons.


Constructor Summary
Intzilla()
          Constructs a large integer with a default value of zero.
Intzilla(java.lang.String s)
          Constructs a large integer from the given string.
 
Method Summary
 Intzilla div(Intzilla divisor)
          Integer-divides the receiver (the dividend) by the given large integer, and returns a new large integer representing the [integer] quotient.
 boolean equals(java.lang.Object n)
          Returns whether or not the given object is a large integer whose value is equal to the receiver.
 boolean isGreaterThan(Intzilla n)
          Returns whether or not the receiver is greater than the given large integer.
 boolean isLessThan(Intzilla n)
          Returns whether or not the receiver is less than the given large integer.
 Intzilla minus(Intzilla subtrahend)
          Subtracts the given large integer from the receiver (the minuend), and returns a new large integer representing the difference.
 Intzilla mod(Intzilla divisor)
          Returns the remainder that results from the division of the receiver by the given large integer (i.e., the modulo or mod operation).
 Intzilla plus(Intzilla addend)
          Adds the given large integer to the receiver (another addend), and returns a new large integer representing the sum.
 Intzilla times(Intzilla factor)
          Multiplies the given large integer from the receiver (another factor), and returns a new large integer representing the product.
 java.lang.String toString()
          Returns a string representation of the receiver.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Intzilla

public Intzilla()
Constructs a large integer with a default value of zero.


Intzilla

public Intzilla(java.lang.String s)
Constructs a large integer from the given string.

Parameters:
s - The string representing the large integer: it should look like a typical signed integer (i.e., a sequence of digits with no intervening spaces, with an initial - sign for negative values. Leading zeroes are allowed, as is a single leading + sign. Whitespace before or after the number proper is allowed and is trimmed (ignored) before parsing.
Method Detail

toString

public java.lang.String toString()
Returns a string representation of the receiver. Unlike standard integers, the large integer string representation always prepends a sign ("+" or "-") unless its value is zero.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object n)
Returns whether or not the given object is a large integer whose value is equal to the receiver.

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

isGreaterThan

public boolean isGreaterThan(Intzilla n)
Returns whether or not the receiver is greater than the given large integer.

Parameters:
n - The large integer to compare
Returns:
Whether or not the receiver is greater than n

isLessThan

public boolean isLessThan(Intzilla n)
Returns whether or not the receiver is less than the given large integer.

Parameters:
n - The large integer to compare
Returns:
Whether or not the receiver is less than n

plus

public Intzilla plus(Intzilla addend)
Adds the given large integer to the receiver (another addend), and returns a new large integer representing the sum.

Parameters:
addend - The large integer to add
Returns:
The sum of the receiver and addend

minus

public Intzilla minus(Intzilla subtrahend)
Subtracts the given large integer from the receiver (the minuend), and returns a new large integer representing the difference.

Parameters:
subtrahend - The large integer to subtract
Returns:
The receiver minus subtrahend

times

public Intzilla times(Intzilla factor)
Multiplies the given large integer from the receiver (another factor), and returns a new large integer representing the product.

Parameters:
factor - The large integer to multiply
Returns:
The product of the receiver and factor

div

public Intzilla div(Intzilla divisor)
Integer-divides the receiver (the dividend) by the given large integer, and returns a new large integer representing the [integer] quotient.

Parameters:
divisor - The large integer with which to divide
Returns:
The quotient of the receiver and divisor

mod

public Intzilla mod(Intzilla divisor)
Returns the remainder that results from the division of the receiver by the given large integer (i.e., the modulo or mod operation).

Parameters:
divisor - The large integer with which to divide
Returns:
The remainder of the receiver divided by divisor