org.znerd.math
Class AbstractCompositeNumber
java.lang.Object
|
+--java.lang.Number
|
+--org.znerd.math.RealNumber
|
+--org.znerd.math.CompositeNumber
|
+--org.znerd.math.AbstractCompositeNumber
- Direct Known Subclasses:
- Power, Product
- public abstract class AbstractCompositeNumber
- extends CompositeNumber
Abstract base class for CompositeNumber
implementations. This
implementation is based on an array. Concrete subclasses should initialize
the array upon construction.
- Version:
- $Revision: 1.1 $ $Date: 2002/06/05 22:23:15 $
- Author:
- Ernst de Haan (znerd@FreeBSD.org)
- See Also:
- Serialized Form
Methods inherited from class org.znerd.math.RealNumber |
abs,
add,
byteValue,
compareTo,
compareTo,
compareToImpl,
divide,
doubleValue,
equals,
fitsByte,
fitsDouble,
fitsFloat,
fitsInt,
fitsLong,
fitsShort,
floatValue,
getSign,
intValue,
invert,
longValue,
multiply,
negate,
pow,
shortValue,
subtract,
toBigDecimal,
toBigDecimal,
toBigInteger,
toString,
trunc |
AbstractCompositeNumber
protected AbstractCompositeNumber(int sign,
String asString,
RealNumber[] elements)
- Constructs a new
AbstractCompositeNumber
object.
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.elements
- the elements for this composite number, not null
, not
empty and not containing any null
values.
getElements
public RealNumber[] getElements()
- Description copied from class: CompositeNumber
- Returns the operands.
- Overrides:
- getElements in class CompositeNumber
- Tags copied from class: CompositeNumber
- Returns:
- a new array, containing the operands.
getElementCount
public int getElementCount()
- Description copied from class: CompositeNumber
- Counts the number of operands.
- Overrides:
- getElementCount in class CompositeNumber
- Tags copied from class: CompositeNumber
- Returns:
- the operand count, >= 0.
getElement
public RealNumber getElement(int n)
throws IndexOutOfBoundsException
- Description copied from class: CompositeNumber
- Returns the nth operand.
- Overrides:
- getElement in class CompositeNumber
- Tags copied from class: CompositeNumber
- 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 < 0
n >= operandCount
See http://jump-math.sourceforge.net/.