Class AbstractCompositeNumber
java.lang.Object
java.lang.Number
org.znerd.math.RealNumber
org.znerd.math.CompositeNumber
org.znerd.math.AbstractCompositeNumber
- All Implemented Interfaces:
Serializable, Comparable, RoundingModes
Abstract base class for
CompositeNumber implementations. This
implementation is based on an array. Concrete subclasses should initialize
the array upon construction.- Version:
- $Revision: 1.3 $ $Date: 2002/08/16 21:54:40 $
- 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
ConstructorsModifierConstructorDescriptionprotectedAbstractCompositeNumber(int sign, String asString, RealNumber[] elements) Constructs a newAbstractCompositeNumberobject. -
Method Summary
Modifier and TypeMethodDescriptiongetElement(int n) Returns the nth operand.intCounts the number of operands.Returns the operands.Methods inherited from class RealNumber
abs, add, byteValue, compareTo, compareTo, compareToImpl, divide, doubleValue, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, getSign, intValue, invert, longValue, multiply, negate, pow, powImpl, round, shortValue, subtract, toBigDecimal, toBigDecimal, toBigInteger, toString, trunc
-
Constructor Details
-
AbstractCompositeNumber
Constructs a newAbstractCompositeNumberobject. The sign of the value needs to be specified. Any negative value is interpreted as meaning that the value of this number is negative. Any positive value is interpreted as meaning that the value of this number is positive.- Parameters:
sign- the sign of this number.asString- a textual presentation for this number, notnullelements- the elements for this composite number, notnull, not empty and not containing anynullvalues.
-
-
Method Details
-
getElements
Description copied from class:CompositeNumberReturns the operands.- Specified by:
getElementsin classCompositeNumber- Returns:
- a new array, containing the operands.
-
getElementCount
public int getElementCount()Description copied from class:CompositeNumberCounts the number of operands.- Specified by:
getElementCountin classCompositeNumber- Returns:
- the operand count, >= 0.
-
getElement
Description copied from class:CompositeNumberReturns the nth operand.- Specified by:
getElementin classCompositeNumber- Parameters:
n- the index of the operand, >= 0 and <CompositeNumber.getElementCount().- Returns:
- the nth operand, not
null. - Throws:
IndexOutOfBoundsException- if one of the following applies:n < 0n >= operandCount
-