org.znerd.math
Class BasicDigitSet

java.lang.Object
  extended by java.lang.Number
      extended by org.znerd.math.RealNumber
          extended by org.znerd.math.RationalNumber
              extended by org.znerd.math.DigitSet
                  extended by org.znerd.math.BasicDigitSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, RoundingModes

public final class BasicDigitSet
extends DigitSet

Basic implementation of a DigitSet.

Version:
$Revision: 1.15 $ $Date: 2002/08/16 19:49:03 $
Author:
Ernst de Haan (znerd@FreeBSD.org)
See Also:
Serialized Form

Field 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 BasicDigitSet(boolean positive, int radix, int[] digits, int exponent)
          Creates a new BasicDigitSet instance.
 
Method Summary
 int[] getDigits()
          Returns a new array containing all the digits.
 int getExponent()
          Returns the exponent.
 int getPrecision()
          Returns the precision, the total number of digits.
 int getRadix()
          Returns the radix or base.
 DigitSet toPrecisionImpl(int precision)
          Returns a digit set with the specified precision, actual implementation.
 
Methods inherited from class org.znerd.math.DigitSet
toPrecision
 
Methods inherited from class org.znerd.math.RationalNumber
add, add, compareTo, compareToImpl, compareToImpl, compareToImpl2, divide, divide, doubleValue, getDenominator, getNumerator, invert, multiply, multiply, negate, pow, powImpl, powImpl, subtract, subtract, toBigDecimal, toBigDecimal, trunc
 
Methods inherited from class org.znerd.math.RealNumber
abs, byteValue, compareTo, compareTo, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, getSign, intValue, longValue, pow, round, shortValue, toBigInteger, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicDigitSet

protected BasicDigitSet(boolean positive,
                        int radix,
                        int[] digits,
                        int exponent)
                 throws java.lang.IllegalArgumentException
Creates a new BasicDigitSet instance.

Parameters:
positive - indication if the number is positive or not.
radix - the radix for the number, always >= 2 and <= RealNumber.MAXIMUM_RADIX.
digits - the digits, not null.
exponent - the exponent for the number.
Throws:
java.lang.IllegalArgumentException - if radix < 2 || radix > RealNumber.MAXIMUM_RADIX || digits == null || digits[i] < 0 || || digits[i] >= radix, where i >= 0 && i < digits.length.
Method Detail

getRadix

public int getRadix()
Description copied from class: DigitSet
Returns the radix or base. The radix is for example 10 for a decimal number and 16 for a hexadecimal number. A binary number has the smallest radix, 2.

Specified by:
getRadix in class DigitSet
Returns:
the radix, always > 1.

getExponent

public int getExponent()
Description copied from class: DigitSet
Returns the exponent.

Specified by:
getExponent in class DigitSet
Returns:
the exponent.

getDigits

public int[] getDigits()
Description copied from class: DigitSet
Returns a new array containing all the digits. Every digit in the returned array is an int value between 0 (inclusive) and the radix (exclusive).

Specified by:
getDigits in class DigitSet
Returns:
a new array containing all the digits; r != null && r[i] >= 0 && r[i] < getRadix(), where r is the return value and i is an int between 0 and r.length.

getPrecision

public int getPrecision()
Description copied from class: DigitSet
Returns the precision, the total number of digits.

Specified by:
getPrecision in class DigitSet
Returns:
the precision, always >= 0.

toPrecisionImpl

public DigitSet toPrecisionImpl(int precision)
Description copied from class: DigitSet
Returns a digit set with the specified precision, actual implementation. This method is called from DigitSet.toPrecision(int).

Specified by:
toPrecisionImpl in class DigitSet
Parameters:
precision - the precision, guaranteed to be >= 1 and < DigitSet.getPrecision().
Returns:
a DigitSet that is equal to this number, truncated to the specified precision.


See http://jump-math.sourceforge.net/.