Class Power
- All Implemented Interfaces:
Serializable, Comparable, RoundingModes
A power, consisting of a base and an exponent.
- Version:
- $Revision: 1.3 $ $Date: 2002/08/16 20:51:08 $
- Author:
- Ernst de Haan (znerd@FreeBSD.org)
- See Also:
-
Field Summary
Fields inherited from class RealNumber
MAXIMUM_RADIXFields inherited from interface RoundingModes
ROUND_CEILING, ROUND_DOWN, ROUND_FLOOR, ROUND_UP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPower(RealNumber base, RealNumber exponent) Constructs aPowerwith the specified base and exponent. -
Method Summary
Modifier and TypeMethodDescriptionstatic PowercreateInstance(RealNumber base, RealNumber exponent) Returns aPowerwith the specified operands.protected static intdetermineSign(RealNumber base, RealNumber exponent) Computes the sign of a power with the specified operands.getBase()Returns the base of this power.Returns the exponent of this power.toBigDecimal(int precision, int roundingMode) Converts the value of this number to aBigDecimalwith the specified precision and rounding mode.trunc()Rounds to an integer number towards 0.Methods inherited from class AbstractCompositeNumber
getElement, getElementCount, getElementsMethods inherited from class 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, toBigInteger, toString
-
Constructor Details
-
Power
Constructs aPowerwith the specified base and exponent.- Parameters:
base- the base for the power, notnull.exponent- the exponent for the power, notnull.- Throws:
IllegalArgumentException- ifbase == null || exponent == null.
-
-
Method Details
-
createInstance
public static Power createInstance(RealNumber base, RealNumber exponent) throws IllegalArgumentException Returns aPowerwith the specified operands.- Parameters:
base- the base for the power, notnull.exponent- the exponent for the power, notnull.- Returns:
- the
Powerinstance, possibly newly constructed. - Throws:
IllegalArgumentException- ifbase == null || exponent == null.
-
determineSign
protected static int determineSign(RealNumber base, RealNumber exponent) throws IllegalArgumentException Computes the sign of a power with the specified operands.- Parameters:
base- the base for the power, notnull.exponent- the exponent for the power, notnull.- Returns:
- the
Powerinstance, possibly newly constructed. - Throws:
IllegalArgumentException- ifbase == null || exponent == null.
-
getBase
-
getExponent
Returns the exponent of this power.- Returns:
- the exponent, never
null.
-
toBigDecimal
Description copied from class:RealNumberConverts the value of this number to aBigDecimalwith the specified precision and rounding mode.- Specified by:
toBigDecimalin classRealNumber- Parameters:
precision- the number of digits behind the decimal point, >= 0.roundingMode- the rounding mode to use, one of the modes defined in classBigDecimal.- Returns:
- a
BigDecimalwith the rounded value of this, nevernull. - Throws:
IllegalArgumentException- if one of the following applies:- precision < 0
- roundingMode is not one of the valid rounding modes
defined in class
BigDecimal
-
trunc
Description copied from class:RealNumberRounds to an integer number towards 0.- Overrides:
truncin classRealNumber- Returns:
- this real number truncated to an integer, never
null.
-