Class BasicDigitSet

All Implemented Interfaces:
Serializable, 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:
  • Constructor Details

    • BasicDigitSet

      protected BasicDigitSet(boolean positive, int radix, int[] digits, int exponent) throws 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:
      IllegalArgumentException - if radix < 2 || radix > RealNumber.MAXIMUM_RADIX || digits == null || digits[i] < 0 || || digits[i] >= radix, where i >= 0 && i < digits.length.
  • Method Details

    • 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.