Class IntegerNumber

All Implemented Interfaces:
Serializable, Comparable, RoundingModes
Direct Known Subclasses:
BigIntegerNumber, SmallIntegerNumber

public abstract class IntegerNumber extends RationalNumber
An immutable integer number. The base for all integer numbers. It extends RationalNumber by offering narrowed numeric computations for integer numbers.

Some IntegerNumber numeric computations are narrowed compared to their more general RationalNumber equivalents. For instance, adding two integer numbers will result in a integer number. The computations concerned are:

add(IntegerNumber)
adding two integer numbers will result in another integer number
subtract(RationalNumber)
subtracting one rational number from another will result in an integer number
multiply(RationalNumber)
multiplying two integer numbers will result in another integer number

Concrete subclasses must at least provide implementations for the following methods:

getSign()
Determines the sign of this number
negate()
Computes -this
add(IntegerNumber)
Computes this+n, where n is an integer number
multiply(IntegerNumber)
Computes this*n, where n is an integer number
integerDivide(IntegerNumber)
Computes the integer result of a division
longValue()
Converts the value of this number to a long
doubleValue()
Converts the value of this number to a double
toByteArray()
Converts the value of this number to a set of bytes that represent the two's complement of this number

Subclasses are encouraged to override as many methods as they can in order to optimize the implementation. Those methods marked as final need no further optimization.

Version:
$Revision: 1.13 $ $Date: 2004/04/15 21:50:12 $
Author:
Ernst de Haan (znerd@FreeBSD.org)
See Also: