Class CompositeNumber
java.lang.Object
java.lang.Number
org.znerd.math.RealNumber
org.znerd.math.CompositeNumber
- All Implemented Interfaces:
Serializable, Comparable, RoundingModes
- Direct Known Subclasses:
AbstractCompositeNumber, Sum
A composite real number. Examples of composite numbers include
sines, logarithms, powers, sums and products.
- 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
ConstructorsModifierConstructorDescriptionprotectedCompositeNumber(int sign, String asString) Constructs a newCompositeNumberobject. -
Method Summary
Modifier and TypeMethodDescriptionabstract RealNumbergetElement(int n) Returns the nth operand.abstract intCounts the number of operands.abstract RealNumber[]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
-
CompositeNumber
Constructs a newCompositeNumberobject. 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, either a positive number if the number is greater than zero, 0 if the number equals zero or a negative number if the number is smaller than zero.asString- a textual presentation of this number, notnull.- Throws:
IllegalArgumentException- ifasString == null.
-
-
Method Details
-
getElements
Returns the operands.- Returns:
- a new array, containing the operands.
-
getElementCount
public abstract int getElementCount()Counts the number of operands.- Returns:
- the operand count, >= 0.
-
getElement
Returns the nth operand.- Parameters:
n- the index of the operand, >= 0 and <getElementCount().- Returns:
- the nth operand, not
null. - Throws:
IndexOutOfBoundsException- if one of the following applies:n < 0n >= operandCount
-