|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.lang.Number
|
+--org.znerd.math.RealNumber
|
+--org.znerd.math.CompositeNumber
|
+--org.znerd.math.Sum
A sum of two real numbers.
Instances of Sum must be obtained by using one of the
createInstance() factory methods.
| Fields inherited from class org.znerd.math.RealNumber |
MAXIMUM_RADIX |
| Constructor Summary | |
protected |
Sum(RealNumber a,
RealNumber b)
Constructs a Sum based on the 2 specified operands. |
| Method Summary | |
protected int |
compareToImpl(RealNumber n)
Compares this number with the specified number, second level. |
static Sum |
createInstance(RealNumber a,
RealNumber b)
Returns a Sum with the specified operands. |
RealNumber |
getElement(int n)
Returns the nth operand. |
int |
getElementCount()
Counts the number of operands. |
RealNumber[] |
getElements()
Returns the operands. |
BigDecimal |
toBigDecimal(int precision,
int roundingMode)
Converts the value of this number to a BigDecimal with the
specified precision and rounding mode. |
IntegerNumber |
trunc()
Rounds to an integer number towards 0. |
| Methods inherited from class org.znerd.math.RealNumber |
abs,
add,
byteValue,
compareTo,
compareTo,
divide,
doubleValue,
equals,
fitsByte,
fitsDouble,
fitsFloat,
fitsInt,
fitsLong,
fitsShort,
floatValue,
getSign,
intValue,
invert,
longValue,
multiply,
negate,
pow,
shortValue,
subtract,
toBigDecimal,
toBigInteger,
toString |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
protected Sum(RealNumber a,
RealNumber b)
throws IllegalArgumentException,
CanNotCompareException
Sum based on the 2 specified operands.a - the first operand for the sum, not null.b - the second operand for the sum, not null.a == null or b == null or both.| Method Detail |
public static Sum createInstance(RealNumber a,
RealNumber b)
throws IllegalArgumentException,
CanNotCompareException
Sum with the specified operands.a - the first operand, not null.b - the second operand, not null.Sum instance, possibly newly constructed.a == null or b == null or both.
protected int compareToImpl(RealNumber n)
throws IllegalArgumentException,
CanNotCompareException
The implementation of this method in class RealNumber throws
a CanNotCompareException. Concrete subclasses are encouraged to
improve this behaviour by overriding this method.
Note that this method does not check if n == null. This
is already done in RealNumber.compareTo(RealNumber).
n - the number to compare to, guaranteed to be not null.
public BigDecimal toBigDecimal(int precision,
int roundingMode)
throws IllegalArgumentException
BigDecimal with the
specified precision and rounding mode.precision - the number of digits behind the decimal point.roundingMode - the rounding mode to use, one of the modes defined
in class BigDecimal.BigDecimal with the rounded value of this.BigDecimal.public IntegerNumber trunc()
public RealNumber[] getElements()
public int getElementCount()
public RealNumber getElement(int n)
throws IndexOutOfBoundsException
n - the index of the operand, >= 0 and <
CompositeNumber.getElementCount().null.n < 0n >= operandCount
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||