Class BasicDigitSet
java.lang.Object
java.lang.Number
org.znerd.math.RealNumber
org.znerd.math.RationalNumber
org.znerd.math.DigitSet
org.znerd.math.BasicDigitSet
- All Implemented Interfaces:
Serializable, Comparable, RoundingModes
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:
-
Field Summary
Fields inherited from class RealNumber
MAXIMUM_RADIXFields inherited from interface RoundingModes
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBasicDigitSet(boolean positive, int radix, int[] digits, int exponent) Creates a newBasicDigitSetinstance. -
Method Summary
Modifier and TypeMethodDescriptionint[]Returns a new array containing all the digits.intReturns the exponent.intReturns the precision, the total number of digits.intgetRadix()Returns the radix or base.toPrecisionImpl(int precision) Returns a digit set with the specified precision, actual implementation.Methods inherited from class DigitSet
toPrecisionMethods inherited from class RationalNumber
add, add, compareTo, compareToImpl, compareToImpl, compareToImpl2, divide, divide, doubleValue, getDenominator, getNumerator, invert, multiply, multiply, negate, pow, powImpl, powImpl, subtract, subtract, toBigDecimal, toBigDecimal, truncMethods inherited from class RealNumber
abs, byteValue, compareTo, compareTo, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, getSign, intValue, longValue, pow, round, shortValue, toBigInteger, toString
-
Constructor Details
-
BasicDigitSet
protected BasicDigitSet(boolean positive, int radix, int[] digits, int exponent) throws IllegalArgumentException Creates a newBasicDigitSetinstance.- 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, notnull.exponent- the exponent for the number.- Throws:
IllegalArgumentException- ifradix < 2 || radix >, whereRealNumber.MAXIMUM_RADIX|| digits == null || digits[i] < 0 || || digits[i] >= radixi >= 0 && i < digits.length.
-
-
Method Details
-
getRadix
-
getExponent
public int getExponent()Description copied from class:DigitSetReturns the exponent.- Specified by:
getExponentin classDigitSet- Returns:
- the exponent.
-
getDigits
public int[] getDigits()Description copied from class:DigitSetReturns a new array containing all the digits. Every digit in the returned array is anintvalue between 0 (inclusive) and the radix (exclusive). -
getPrecision
public int getPrecision()Description copied from class:DigitSetReturns the precision, the total number of digits.- Specified by:
getPrecisionin classDigitSet- Returns:
- the precision, always >= 0.
-
toPrecisionImpl
Description copied from class:DigitSetReturns a digit set with the specified precision, actual implementation. This method is called fromDigitSet.toPrecision(int).- Specified by:
toPrecisionImplin classDigitSet- Parameters:
precision- the precision, guaranteed to be >= 1 and <DigitSet.getPrecision().- Returns:
- a
DigitSetthat is equal to this number, truncated to the specified precision.
-