Class nl.coffee.math.Power
java.lang.Object
|
+--java.lang.Number
|
+--nl.coffee.math.AbstractRealNumber
|
+--nl.coffee.math.AbstractCompositeNumber
|
+--nl.coffee.math.Power
- public class Power
- extends AbstractCompositeNumber
A power, consisting of a base and an exponent.
- Since:
- JUMP_1.0
- Version:
- 1.1 199809.24
- Author:
- Ernst de Haan
- See Also:
- Serialized Form
Field Summary
|
int
|
sign
The sign of this power. |
Methods inherited from class nl.coffee.math.AbstractRealNumber |
abs, add, byteValue, compareTo, divide, doubleValue, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, hashCode, intValue, invert, longValue, multiply, negate, pow, retryCompare, shortValue, subtract, toBigDecimal, toBigInteger |
Methods inherited from class java.lang.Number |
byteValue, doubleValue, floatValue, intValue, longValue, shortValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
sign
protected int sign
- The sign of this power. This field is set only once upon construction.
Power
protected Power(RealNumber base,
RealNumber exponent)
throws java.lang.IllegalArgumentException
- Constructs a
Power
with the specified base and exponent.
- Parameters:
base
- the base for the power.
exponent
- the exponent for the power.- Throws:
- java.lang.IllegalArgumentException - if either argument
is
null
.
createInstance
public static Power createInstance(RealNumber a,
RealNumber b)
throws java.lang.IllegalArgumentException
- Returns a
Power
with the specified operands.
- Parameters:
a
- the first operand.
b
- the second operand.- Returns:
- the
Power
instance, possibly newly constructed. - Throws:
- java.lang.IllegalArgumentException - if either argument is
null
.
determineSign
protected static int determineSign(RealNumber a,
RealNumber b)
- Computes the sign of a power with the specified operands.
- Parameters:
operand1
- the first operand.
operand2
- the second operand.
getBase
public RealNumber getBase()
- Returns the base of this power.
- Returns:
- the base.
getExponent
public RealNumber getExponent()
- Returns the exponent of this power.
- Returns:
- the exponent.
getSign
public int getSign()
- Determines the sign of this number. This method returns -1, 0, or
1 as this number is negative, zero, or positive.
- Returns:
- the sign of this number.
retryCompare
public int retryCompare(RealNumber n)
throws java.lang.IllegalArgumentException
- Overrides:
- retryCompare in class AbstractRealNumber
toBigDecimal
public java.math.BigDecimal toBigDecimal(int precision,
int roundingMode)
throws java.lang.IllegalArgumentException
trunc
public IntegerNumber trunc()
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object