org.znerd.math
public class Power extends AbstractCompositeNumber
MAXIMUM_RADIX
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP
Modifier | Constructor and Description |
---|---|
protected |
Power(RealNumber base,
RealNumber exponent)
Constructs a
Power with the specified base and exponent. |
Modifier and Type | Method and Description |
---|---|
static Power |
createInstance(RealNumber base,
RealNumber exponent)
Returns a
Power with the specified operands. |
protected static int |
determineSign(RealNumber base,
RealNumber exponent)
Computes the sign of a power with the specified operands.
|
RealNumber |
getBase()
Returns the base of this power.
|
RealNumber |
getExponent()
Returns the exponent of this power.
|
java.math.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.
|
getElement, getElementCount, getElements
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, toBigInteger, toString
protected Power(RealNumber base, RealNumber exponent) throws java.lang.IllegalArgumentException
Power
with the specified base and exponent.base
- the base for the power, not null
.exponent
- the exponent for the power, not null
.java.lang.IllegalArgumentException
- if base == null || exponent == null
.public static Power createInstance(RealNumber base, RealNumber exponent) throws java.lang.IllegalArgumentException
Power
with the specified operands.base
- the base for the power, not null
.exponent
- the exponent for the power, not null
.Power
instance, possibly newly constructed.java.lang.IllegalArgumentException
- if base == null || exponent == null
.protected static int determineSign(RealNumber base, RealNumber exponent) throws java.lang.IllegalArgumentException
base
- the base for the power, not null
.exponent
- the exponent for the power, not null
.Power
instance, possibly newly constructed.java.lang.IllegalArgumentException
- if base == null || exponent == null
.public RealNumber getBase()
null
.public RealNumber getExponent()
null
.public java.math.BigDecimal toBigDecimal(int precision, int roundingMode) throws java.lang.IllegalArgumentException
RealNumber
BigDecimal
with the
specified precision and rounding mode.toBigDecimal
in class RealNumber
precision
- the number of digits behind the decimal point, >= 0.roundingMode
- the rounding mode to use, one of the modes defined in class
BigDecimal
.BigDecimal
with the rounded value of this, never
null
.java.lang.IllegalArgumentException
- if one of the following applies:
BigDecimal
public IntegerNumber trunc()
RealNumber
trunc
in class RealNumber
null
.