Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
RationalNumber
interface 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
numbersubtract(RationalNumber)
--
subtracting one rational number from another will result in an
integer numbermultiply(RationalNumber)
--
multiplying two integer numbers will result in another integer
number
Method Summary | |
IntegerNumber | add(IntegerNumber n)
Computes this+n, where n is an integer number. |
int | compareTo(IntegerNumber n)
|
IntegerNumber | dec()
Computes this-1. |
IntegerNumber | fac()
Computes this!. |
IntegerNumber | gcd(IntegerNumber n)
Computes the greatest common divisor of this and n. |
IntegerNumber | inc()
Computes this+1. |
IntegerNumber | integerDivide(IntegerNumber n)
Computes the integer result of this/n, where n is an integer number. |
boolean | isRelativePrime(IntegerNumber n)
Determines if this and n are relative primes. |
IntegerNumber | multiply(IntegerNumber n)
Computes this*n, where n is an integer number. |
IntegerNumber | remainder(IntegerNumber n)
Computes the remainder of this/n, where n is an integer number. |
IntegerNumber | subtract(IntegerNumber n)
Computes this-n, where n is an integer number. |
java.math.BigDecimal | toBigDecimal()
Converts the value of this number to a BigDecimal . |
java.math.BigInteger | toBigInteger()
Converts the value of this number to a BigInteger . |
byte[] | toByteArray()
Returns the two's-complement representation of this integer number. |
Method Detail |
public int compareTo(IntegerNumber n) throws java.lang.IllegalArgumentException
public IntegerNumber add(IntegerNumber n) throws java.lang.IllegalArgumentException
n
- the number to add to this.null
.public IntegerNumber subtract(IntegerNumber n) throws java.lang.IllegalArgumentException
n
- the number to subtract from this.null
.public IntegerNumber multiply(IntegerNumber n) throws java.lang.IllegalArgumentException
n
- the number to multiply this by.null
.public IntegerNumber dec()
public IntegerNumber inc()
public IntegerNumber fac() throws java.lang.IllegalArgumentException
public IntegerNumber integerDivide(IntegerNumber n) throws java.lang.ArithmeticException, java.lang.IllegalArgumentException
n
- the number to divide this by.null
.public IntegerNumber remainder(IntegerNumber n) throws java.lang.ArithmeticException, java.lang.IllegalArgumentException
n
- the number to divide this by.null
.public IntegerNumber gcd(IntegerNumber n) throws java.lang.IllegalArgumentException
n
- the other integer number.null
.public boolean isRelativePrime(IntegerNumber n) throws java.lang.IllegalArgumentException
n
- the other integer number.true
if this and n are relative primes,
false
otherwise.null
.public byte[] toByteArray()
public java.math.BigInteger toBigInteger()
BigInteger
.BigInteger
with the exact 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.Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |