| 
|||||||||
| 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
An immutable integer number. The base for all integer numbers. It extends
 RationalNumber 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)subtract(RationalNumber)multiply(RationalNumber)Concrete subclasses must at least provide implementations for the following methods:
getSign()negate()add(IntegerNumber)multiply(IntegerNumber)integerDivide(IntegerNumber)longValue()longdoubleValue()doubletoByteArray()Subclasses are encouraged to override as many methods as they can in
 order to optimize the implementation. Those methods marked as
 final need no further optimization.
| Fields inherited from class org.znerd.math.RealNumber | 
MAXIMUM_RADIX | 
| Constructor Summary | |
protected  | 
IntegerNumber(int sign,
              String asString)
 | 
| Method Summary | |
 RealNumber | 
abs()
Computes |this|.  | 
 IntegerNumber | 
absInteger()
 | 
abstract  IntegerNumber | 
add(IntegerNumber n)
Computes this + n, where n is an integer number.  | 
 RationalNumber | 
add(RationalNumber n)
Computes this+n, where n is a rational number.  | 
protected  int | 
compareTo(IntegerNumber n)
 | 
protected  int | 
compareToImpl(IntegerNumber n)
 | 
protected  int | 
compareToImpl(RationalNumber n)
 | 
 IntegerNumber | 
dec()
Computes this-1.  | 
 RationalNumber | 
divide(RationalNumber n)
Computes this/n, where n is a rational number.  | 
 IntegerNumber | 
fac()
Computes this!.  | 
 IntegerNumber | 
gcd(IntegerNumber n)
Computes the greatest common divisor of this and n.  | 
 IntegerNumber | 
inc()
Computes this+1.  | 
abstract  IntegerNumber | 
integerDivide(IntegerNumber n)
Computes the integer result of this/n, where n is an integer number.  | 
 RealNumber | 
invert()
Computes 1/this.  | 
 boolean | 
isRelativePrime(IntegerNumber n)
Determines if this and n are relative primes.  | 
abstract  IntegerNumber | 
multiply(IntegerNumber n)
Computes this * n, where n is an integer number.  | 
 RationalNumber | 
multiply(RationalNumber n)
Computes this*n, where n is a rational number.  | 
 RealNumber | 
negate()
Computes -this.  | 
 IntegerNumber | 
negateInteger()
 | 
 RationalNumber | 
pow(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.  | 
abstract  DigitSet | 
round(int radix,
      int precision,
      RoundingMode roundingMode)
Rounds to the specified radix, using the specified precision and rounding mode.  | 
 IntegerNumber | 
subtract(IntegerNumber n)
Computes this - n, where n is an integer number.  | 
 RationalNumber | 
subtract(RationalNumber n)
Computes this-n, where n is a rational number.  | 
 BigDecimal | 
toBigDecimal()
Converts the value of this number to a BigDecimal. | 
 BigDecimal | 
toBigDecimal(int precision)
Converts the value of this number to a BigDecimal with the
 specified precision. | 
 BigDecimal | 
toBigDecimal(int precision,
             int roundingMode)
Converts the value of this number to a BigDecimal with the
 specified precision and rounding mode. | 
 BigInteger | 
toBigInteger()
Converts the value of this number to a BigInteger. | 
abstract  byte[] | 
toByteArray()
Returns the two's-complement representation of this integer number.  | 
 IntegerNumber | 
trunc()
Rounds to an integer number towards 0.  | 
| Methods inherited from class org.znerd.math.RationalNumber | 
add, 
compareTo, 
compareToImpl, 
compareToImpl2, 
divide, 
doubleValue, 
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, 
intValue, 
longValue, 
shortValue, 
toString | 
| Methods inherited from class java.lang.Object | 
clone, 
finalize, 
getClass, 
hashCode, 
notify, 
notifyAll, 
wait, 
wait, 
wait | 
| Constructor Detail | 
protected IntegerNumber(int sign,
                        String asString)
| Method Detail | 
protected int compareToImpl(RationalNumber n)
                     throws CanNotCompareException
protected final int compareTo(IntegerNumber n)
                       throws CanNotCompareException
protected int compareToImpl(IntegerNumber n)
                     throws CanNotCompareException
public abstract 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 final RealNumber abs()
null and always with a value
    >= 0.public final IntegerNumber absInteger()
public final RealNumber negate()
null.public IntegerNumber negateInteger()
public RealNumber invert()
                  throws ArithmeticException
null.
public RationalNumber add(RationalNumber n)
                   throws IllegalArgumentException
n - the number to add to this.null.
public abstract IntegerNumber add(IntegerNumber n)
                           throws IllegalArgumentException
n - the number to add to this, not null.null.null.
public RationalNumber subtract(RationalNumber n)
                        throws IllegalArgumentException
n - the number to subtract from this.null.
public IntegerNumber subtract(IntegerNumber n)
                       throws IllegalArgumentException
n - the number to subtract from this, not null.null.n == null.
public RationalNumber multiply(RationalNumber n)
                        throws IllegalArgumentException
n - the number to multiply this by.null.
public abstract IntegerNumber multiply(IntegerNumber n)
                                throws IllegalArgumentException
n - the number to multiply this by, not null.null.n == null.
public RationalNumber divide(RationalNumber n)
                      throws IllegalArgumentException,
                             ArithmeticException
n - the number to divide this by.null.
public RationalNumber pow(IntegerNumber n)
                   throws IllegalArgumentException
n - the exponent.null.public IntegerNumber dec()
public IntegerNumber inc()
public IntegerNumber fac()
                  throws ArithmeticException
null.
public IntegerNumber remainder(IntegerNumber n)
                        throws ArithmeticException,
                               IllegalArgumentException
n - the number to divide this by.null.
public IntegerNumber gcd(IntegerNumber n)
                  throws IllegalArgumentException
n - the other integer number.null.
public boolean isRelativePrime(IntegerNumber n)
                        throws IllegalArgumentException
n - the other integer number.true if this and n are relative primes,
    false otherwise.null.public BigInteger toBigInteger()
BigInteger.BigInteger with the value of this.public BigDecimal toBigDecimal()
BigDecimal. A
 precision nor a rounding mode need to be specified for integer numbers.BigDecimal with the exact value of this.
public BigDecimal toBigDecimal(int precision)
                        throws 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 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()
null.public abstract byte[] toByteArray()
public abstract IntegerNumber integerDivide(IntegerNumber n)
                                     throws ArithmeticException,
                                            IllegalArgumentException
n - the number to divide this by.null.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||