Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Interface nl.coffee.math.IntegerNumber

Implementing Classes:
AbstractIntegerNumber

public abstract interface IntegerNumber
extends RationalNumber
An immutable integer number. This interface provides the base for all integer numbers. It extends 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:

Since:
JUMP_1.0
Version:
1.1 199809.24
Author:
Ernst de Haan

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

compareTo

public int compareTo(IntegerNumber n)
             throws java.lang.IllegalArgumentException

add

public IntegerNumber add(IntegerNumber n)
                                throws java.lang.IllegalArgumentException
Computes this+n, where n is an integer number.
Parameters:
n - the number to add to this.
Returns:
the sum of this and n.
Throws:
java.lang.IllegalArgumentException - if the argument is null.

subtract

public IntegerNumber subtract(IntegerNumber n)
                                     throws java.lang.IllegalArgumentException
Computes this-n, where n is an integer number.
Parameters:
n - the number to subtract from this.
Returns:
this minus n.
Throws:
java.lang.IllegalArgumentException - if the argument is null.

multiply

public IntegerNumber multiply(IntegerNumber n)
                                     throws java.lang.IllegalArgumentException
Computes this*n, where n is an integer number.
Parameters:
n - the number to multiply this by.
Returns:
the product of this and n.
Throws:
java.lang.IllegalArgumentException - if the argument is null.

dec

public IntegerNumber dec()
Computes this-1.
Returns:
this decreased by 1.

inc

public IntegerNumber inc()
Computes this+1.
Returns:
this increased by 1.

fac

public IntegerNumber fac()
                                throws java.lang.IllegalArgumentException
Computes this!. The value of this cannot be negative.
Returns:
the faculty of this.
Throws:
java.lang.IllegalArgumentException - if the value of this < 0.

integerDivide

public IntegerNumber integerDivide(IntegerNumber n)
                                          throws java.lang.ArithmeticException,
                                                 java.lang.IllegalArgumentException
Computes the integer result of this/n, where n is an integer number.
Parameters:
n - the number to divide this by.
Returns:
the integer result of this divided by n.
Throws:
java.lang.ArithmeticException - if the value of the argument number is zero.
java.lang.IllegalArgumentException - if the argument is null.

remainder

public IntegerNumber remainder(IntegerNumber n)
                                      throws java.lang.ArithmeticException,
                                             java.lang.IllegalArgumentException
Computes the remainder of this/n, where n is an integer number.
Parameters:
n - the number to divide this by.
Returns:
the remainder.
Throws:
java.lang.ArithmeticException - if the value of the argument number is zero.
java.lang.IllegalArgumentException - if the argument is null.

gcd

public IntegerNumber gcd(IntegerNumber n)
                                throws java.lang.IllegalArgumentException
Computes the greatest common divisor of this and n.
Parameters:
n - the other integer number.
Returns:
the greatest common divisor.
Throws:
java.lang.IllegalArgumentException - if n is null.

isRelativePrime

public boolean isRelativePrime(IntegerNumber n)
                       throws java.lang.IllegalArgumentException
Determines if this and n are relative primes.
Parameters:
n - the other integer number.
Returns:
true if this and n are relative primes, false otherwise.
Throws:
java.lang.IllegalArgumentException - if n is null.

toByteArray

public byte[] toByteArray()
Returns the two's-complement representation of this integer number. The array is big-endian (i.e., the most significant byte is in the [0] position). The array contains the minimum number of bytes required to represent the number.
Returns:
a byte array containing the bits of this integer number.

toBigInteger

public java.math.BigInteger toBigInteger()
Converts the value of this number to a BigInteger.
Returns:
a BigInteger with the exact value of this.

toBigDecimal

public java.math.BigDecimal toBigDecimal()
Converts the value of this number to a BigDecimal. A precision nor a rounding mode need to be specified for integer numbers.
Returns:
a 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