org.znerd.math
Class AbstractCompositeNumber

java.lang.Object
  extended by java.lang.Number
      extended by org.znerd.math.RealNumber
          extended by org.znerd.math.CompositeNumber
              extended by org.znerd.math.AbstractCompositeNumber
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, RoundingModes
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.3 $ $Date: 2002/08/16 21:54:40 $
Author:
Ernst de Haan (znerd@FreeBSD.org)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.znerd.math.RealNumber
MAXIMUM_RADIX
 
Fields inherited from interface org.znerd.math.RoundingModes
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP
 
Constructor Summary
protected AbstractCompositeNumber(int sign, java.lang.String asString, RealNumber[] elements)
          Constructs a new AbstractCompositeNumber object.
 
Method Summary
 RealNumber getElement(int n)
          Returns the nth operand.
 int getElementCount()
          Counts the number of operands.
 RealNumber[] getElements()
          Returns the operands.
 
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, powImpl, round, shortValue, subtract, toBigDecimal, toBigDecimal, toBigInteger, toString, trunc
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractCompositeNumber

protected AbstractCompositeNumber(int sign,
                                  java.lang.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.
asString - a textual presentation for this number, not null
elements - the elements for this composite number, not null, not empty and not containing any null values.
Method Detail

getElements

public RealNumber[] getElements()
Description copied from class: CompositeNumber
Returns the operands.

Specified by:
getElements in class CompositeNumber
Returns:
a new array, containing the operands.

getElementCount

public int getElementCount()
Description copied from class: CompositeNumber
Counts the number of operands.

Specified by:
getElementCount in class CompositeNumber
Returns:
the operand count, >= 0.

getElement

public RealNumber getElement(int n)
                      throws java.lang.IndexOutOfBoundsException
Description copied from class: CompositeNumber
Returns the nth operand.

Specified by:
getElement in class CompositeNumber
Parameters:
n - the index of the operand, >= 0 and < CompositeNumber.getElementCount().
Returns:
the nth operand, not null.
Throws:
java.lang.IndexOutOfBoundsException - if one of the following applies:
  1. n < 0
  2. n >= operandCount


See http://jump-math.sourceforge.net/.