|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Number | +--org.znerd.math.RealNumber | +--org.znerd.math.RationalNumber | +--org.znerd.math.IntegerNumber | +--org.znerd.math.SmallIntegerNumber
Implementation of an IntegerNumber
based on a
int
value.
Instances must be obtained by using one of the
createInstance()
factory methods. Using this approach,
instances can be transparently cached by this class.
Field Summary | |
int |
_value
The int this IntegerNumber implementation
is based on. |
static SmallIntegerNumber |
MAXIMUM_VALUE
The maximum IntegerNumber that can be represented by this
class. |
static SmallIntegerNumber |
MINIMUM_VALUE
The minimum IntegerNumber that can be represented by this
class. |
static SmallIntegerNumber |
MINUS_ONE
Cached instance that represents the number minus one, -1. |
static SmallIntegerNumber |
MINUS_TWO
Cached instance that represents the number minus two, -2. |
static SmallIntegerNumber |
ONE
Cached instance that represents the number one, 1. |
static SmallIntegerNumber |
TWO
Cached instance that represents the number two, 2. |
static SmallIntegerNumber |
ZERO
Cached instance that represents the number zero, 0. |
Fields inherited from class org.znerd.math.RealNumber |
MAXIMUM_RADIX |
Method Summary | |
IntegerNumber |
add(IntegerNumber n)
Computes this + n, where n is an integer number. |
protected int |
compareToImpl(IntegerNumber n)
|
static SmallIntegerNumber |
createInstance(int n)
Returns an instance of a SmallIntegerNumber based on a
int value. |
IntegerNumber |
dec()
Computes this-1. |
double |
doubleValue()
Returns the value of this number as a double . |
IntegerNumber |
inc()
Computes this+1. |
IntegerNumber |
integerDivide(IntegerNumber n)
Computes the integer result of this/n, where n is an integer number. |
int |
intValue()
Returns the value of this number as an int . |
long |
longValue()
Returns the value of this number as a long . |
IntegerNumber |
multiply(IntegerNumber n)
Computes this * n, where n is an integer number. |
IntegerNumber |
negateInteger()
|
IntegerNumber |
remainder(IntegerNumber n)
Computes the remainder of this/n, where n is an integer number. |
DigitSet |
round(int radix,
int precision,
RoundingMode roundingMode)
Rounds to the specified radix, using the specified precision and rounding mode. |
BigInteger |
toBigInteger()
Converts the value of this number to a BigInteger . |
byte[] |
toByteArray()
Returns the two's-complement representation of this integer number. |
Methods inherited from class org.znerd.math.IntegerNumber |
abs,
absInteger,
add,
compareTo,
compareToImpl,
divide,
fac,
gcd,
invert,
isRelativePrime,
multiply,
negate,
pow,
subtract,
subtract,
toBigDecimal,
toBigDecimal,
toBigDecimal,
trunc |
Methods inherited from class org.znerd.math.RationalNumber |
add,
compareTo,
compareToImpl,
compareToImpl2,
divide,
getDenominator,
getNumerator,
multiply,
pow,
subtract |
Methods inherited from class org.znerd.math.RealNumber |
byteValue,
compareTo,
compareTo,
equals,
fitsByte,
fitsDouble,
fitsFloat,
fitsInt,
fitsLong,
fitsShort,
floatValue,
getSign,
shortValue,
toString |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final SmallIntegerNumber MINIMUM_VALUE
IntegerNumber
that can be represented by this
class.public static final SmallIntegerNumber MAXIMUM_VALUE
IntegerNumber
that can be represented by this
class.public static final SmallIntegerNumber MINUS_TWO
public static final SmallIntegerNumber MINUS_ONE
public static final SmallIntegerNumber ZERO
public static final SmallIntegerNumber ONE
public static final SmallIntegerNumber TWO
public final int _value
int
this IntegerNumber
implementation
is based on.Method Detail |
public static SmallIntegerNumber createInstance(int n)
SmallIntegerNumber
based on a
int
value.n
- the int
to construct a SmallIntegerNumber
from.SmallIntegerNumber
.protected int compareToImpl(IntegerNumber n) throws CanNotCompareException
public DigitSet round(int radix, int precision, RoundingMode roundingMode) throws IllegalArgumentException
radix
- the radix, always >= 2 and <= RealNumber.MAXIMUM_RADIX
.precision
- the precision, always >= 1.roundingMode
- the rounding mode, never null
.radix < 2
|| radix > RealNumber.MAXIMUM_RADIX
|| precision < 1
|| roundingMode == null
.public IntegerNumber negateInteger()
public IntegerNumber add(IntegerNumber n) throws IllegalArgumentException
n
- the number to add to this, not null
.null
.null
.public IntegerNumber multiply(IntegerNumber n) throws IllegalArgumentException
n
- the number to multiply this by, not null
.null
.n == null
.public IntegerNumber dec()
public IntegerNumber inc()
public IntegerNumber integerDivide(IntegerNumber n) throws ArithmeticException, IllegalArgumentException
n
- the number to divide this by.null
.public IntegerNumber remainder(IntegerNumber n) throws ArithmeticException, IllegalArgumentException
n
- the number to divide this by.null
.public long longValue()
long
. This may
involve rounding.long
.public int intValue()
int
. This may
involve rounding.int
.public double doubleValue()
double
. This may
involve rounding.double
.public byte[] toByteArray()
public BigInteger toBigInteger()
BigInteger
.BigInteger
with the value of this.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |