Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Number | +--nl.coffee.math.AbstractRealNumber | +--nl.coffee.math.AbstractRationalNumber | +--nl.coffee.math.AbstractIntegerNumber
IntegerNumber
implementations.
Concrete subclasses must at least provide implementations for the following methods:
getSign()
--
Determines the sign of this numbernegate()
--
Computes -thisadd(IntegerNumber)
--
Computes this+n,
where n is an integer numbermultiply(IntegerNumber)
--
Computes this*n,
where n is an integer numberintegerDivide(IntegerNumber)
--
Computes the integer result of a divisionlongValue()
--
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 numberfinal
need no further optimization.
Constructor Summary | |
AbstractIntegerNumber()
Constructs a new AbstractIntegerNumber . |
Method Summary | |
RationalNumber | add(RationalNumber n)
|
int | compareTo(IntegerNumber n)
|
IntegerNumber | dec()
|
RationalNumber | divide(RationalNumber n)
|
IntegerNumber | fac()
|
IntegerNumber | gcd(IntegerNumber n)
|
IntegerNumber | getDenominator()
Returns the denominator of this rational number. |
IntegerNumber | getNumerator()
Returns the numerator of this rational number. |
int | getSign()
Determines the sign of this number. |
int | hashCode()
|
IntegerNumber | inc()
|
RealNumber | invert()
|
boolean | isRelativePrime(IntegerNumber n)
|
RationalNumber | multiply(RationalNumber n)
|
RealNumber | negate()
Computes -this. |
RationalNumber | pow(IntegerNumber n)
|
IntegerNumber | remainder(IntegerNumber n)
|
RationalNumber | subtract(RationalNumber n)
|
IntegerNumber | subtract(IntegerNumber n)
|
java.math.BigDecimal | toBigDecimal()
Converts the value of this number to a BigDecimal . |
java.math.BigDecimal | toBigDecimal(int precision)
Converts the value of this number to a BigDecimal with the
specified precision. |
java.math.BigDecimal | toBigDecimal(int precision,
int roundingMode)
Converts the value of this number to a BigDecimal with the
specified precision and rounding mode. |
java.math.BigInteger | toBigInteger()
Converts the value of this number to a BigInteger . |
java.lang.String | toString()
Returns a textual representation of this object. |
IntegerNumber | trunc()
Rounds to an integer number towards 0. The implementation of this method in
|
Methods inherited from class nl.coffee.math.AbstractRationalNumber | |
add, add, compareTo, divide, divide, doubleValue, getSign, invert, multiply, multiply, negate, pow, pow, retryCompare, retryCompare, subtract, subtract, toBigDecimal, toBigDecimal, toString, trunc |
Methods inherited from class nl.coffee.math.AbstractRealNumber | |
abs, add, byteValue, compareTo, divide, doubleValue, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, hashCode, intValue, invert, longValue, multiply, negate, pow, retryCompare, shortValue, subtract, toBigDecimal, toBigInteger |
Methods inherited from class java.lang.Number | |
byteValue, doubleValue, floatValue, intValue, longValue, shortValue |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Constructor Detail |
protected AbstractIntegerNumber()
AbstractIntegerNumber
.Method Detail |
public int compareTo(IntegerNumber n) throws java.lang.IllegalArgumentException
public int hashCode()
public abstract int getSign()
The declaration is made abstract, because the implementation in
superclass AbstractRationalNumber
does not make sense
for IntegerNumber
implementations.
public abstract RealNumber negate()
The declaration is made abstract, because the implementation in
superclass AbstractRationalNumber
does not make sense
for IntegerNumber
implementations.
public RealNumber invert() throws java.lang.ArithmeticException
public RationalNumber add(RationalNumber n) throws java.lang.IllegalArgumentException
public RationalNumber subtract(RationalNumber n) throws java.lang.IllegalArgumentException
public IntegerNumber subtract(IntegerNumber n) throws java.lang.IllegalArgumentException
public RationalNumber multiply(RationalNumber n) throws java.lang.IllegalArgumentException
public RationalNumber divide(RationalNumber n) throws java.lang.IllegalArgumentException, java.lang.ArithmeticException
public RationalNumber pow(IntegerNumber n) throws java.lang.IllegalArgumentException
public final IntegerNumber getNumerator()
public final IntegerNumber getDenominator()
public IntegerNumber dec()
public IntegerNumber inc()
public IntegerNumber fac() throws java.lang.IllegalArgumentException
public IntegerNumber remainder(IntegerNumber n) throws java.lang.ArithmeticException, java.lang.IllegalArgumentException
public IntegerNumber gcd(IntegerNumber n) throws java.lang.IllegalArgumentException
public boolean isRelativePrime(IntegerNumber n) throws java.lang.IllegalArgumentException
public java.lang.String toString()
String
of this object.public java.math.BigInteger toBigInteger()
BigInteger
.BigInteger
with the value of this.public java.math.BigDecimal toBigDecimal()
BigDecimal
. A
precision nor a rounding mode need to be specified for integer numbers.BigDecimal
with the exact value of this.public java.math.BigDecimal toBigDecimal(int precision) throws java.lang.IllegalArgumentException
BigDecimal
with the
specified precision. The precision argument is ignored,
because no rounding is needed.
precision
- the number of digits behind the decimal point.BigDecimal
with the exact value of this.public java.math.BigDecimal toBigDecimal(int precision, int roundingMode)
BigDecimal
with the
specified precision and rounding mode. The precision and
roundingMode arguments are ignored, because no rounding is
needed.
precision
- the number of digits behind the decimal point.
roundingMode
- the rounding mode to use, one of the modes defined
in class BigDecimal
.BigDecimal
with the rounded value of this.public final IntegerNumber trunc()
The implementation of this method in
AbstractIntegerNumber
returns this.
Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |