|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
org.znerd.math.RealNumber
org.znerd.math.RationalNumber
org.znerd.math.IntegerNumber
org.znerd.math.BigIntegerNumber
Basic implementation of an integer number. This implementation is based on
a java.math.BigInteger
. It can hold all values from
-2**32 to (2**32 - 1).
createInstance()
factory method.
BigInteger
,
Serialized FormField Summary |
Fields inherited from class org.znerd.math.RealNumber |
MAXIMUM_RADIX |
Fields inherited from interface org.znerd.math.RoundingModes |
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP |
Constructor Summary | |
protected |
BigIntegerNumber(BigInteger n)
Constructs a BigIntegerNumber from a
BigInteger . |
Method Summary | |
IntegerNumber |
add(IntegerNumber n)
Computes this + n, where n is an integer number. |
static BigIntegerNumber |
createInstance(BigInteger n)
Returns an instance of a BigIntegerNumber based on a
java.math.BigInteger . |
double |
doubleValue()
Returns the value of this number as a double . |
int |
hashCode()
|
IntegerNumber |
integerDivide(IntegerNumber n)
Computes the integer result of this/n, where n is an integer number. |
long |
longValue()
Returns the value of this number as a long . |
IntegerNumber |
multiply(IntegerNumber n)
Computes this * n, where n is an integer number. |
protected RationalNumber |
powImpl(int exponent)
|
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, compareToImpl, dec, divide, fac, gcd, inc, invert, isRelativePrime, multiply, negate, negateInteger, powImpl, remainder, subtract, subtract, toBigDecimal, toBigDecimal, toBigDecimal, trunc |
Methods inherited from class org.znerd.math.RationalNumber |
add, compareTo, compareToImpl, compareToImpl2, divide, getDenominator, getNumerator, multiply, pow, powImpl, subtract |
Methods inherited from class org.znerd.math.RealNumber |
byteValue, compareTo, compareTo, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, getSign, intValue, pow, round, shortValue, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected BigIntegerNumber(BigInteger n) throws IllegalArgumentException
BigIntegerNumber
from a
BigInteger
.
n
- the value for the new number, not null
.
IllegalArgumentException
- if n == null
.Method Detail |
public static BigIntegerNumber createInstance(BigInteger n) throws IllegalArgumentException
BigIntegerNumber
based on a
java.math.BigInteger
.
n
- the BigInteger
to construct a BigIntegerNumber
from.
BigIntegerNumber
instance.
IllegalArgumentException
- if n == null
.public int hashCode()
public IntegerNumber add(IntegerNumber n) throws IllegalArgumentException
IntegerNumber
add
in class IntegerNumber
n
- the number to add to this, not null
.
null
.
IllegalArgumentException
- if the argument is
null
.public IntegerNumber multiply(IntegerNumber n) throws IllegalArgumentException
IntegerNumber
multiply
in class IntegerNumber
n
- the number to multiply this by, not null
.
null
.
IllegalArgumentException
- if n == null
.public IntegerNumber integerDivide(IntegerNumber n) throws ArithmeticException, IllegalArgumentException
IntegerNumber
integerDivide
in class IntegerNumber
n
- the number to divide this by.
IllegalArgumentException
- if the argument is
null
.
ArithmeticException
- if the value of the argument number is
zero.protected RationalNumber powImpl(int exponent)
public long longValue()
RealNumber
long
. This may
involve rounding.
longValue
in class RealNumber
long
.public double doubleValue()
RealNumber
double
. This may
involve rounding.
doubleValue
in class RationalNumber
public byte[] toByteArray()
IntegerNumber
toByteArray
in class IntegerNumber
public BigInteger toBigInteger()
IntegerNumber
BigInteger
.
toBigInteger
in class IntegerNumber
BigInteger
with the value of this.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |