java.lang.ObjectIntzilla
public class Intzilla
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 |
---|
public Intzilla()
public Intzilla(java.lang.String s)
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 |
---|
public java.lang.String toString()
"+"
or "-"
) unless its value is zero.
toString
in class java.lang.Object
Object.toString()
public boolean equals(java.lang.Object n)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public boolean isGreaterThan(Intzilla n)
n
- The large integer to compare
public boolean isLessThan(Intzilla n)
n
- The large integer to compare
public Intzilla plus(Intzilla addend)
addend
- The large integer to add
public Intzilla minus(Intzilla subtrahend)
subtrahend
- The large integer to subtract
public Intzilla times(Intzilla factor)
factor
- The large integer to multiply
public Intzilla div(Intzilla divisor)
divisor
- The large integer with which to divide
public Intzilla mod(Intzilla divisor)
divisor
- The large integer with which to divide