pow
Returns a BigDecimal whose value is (this<sup>n</sup>), The power is computed exactly, to unlimited _precision.
The parameter n must be in the range 0 through 999999999, inclusive. ZERO.pow(0) returns BigDecimal.ONE.
Note that future releases may expand the allowable exponent range of this method.
Return
this<sup>n</sup>
Since
1.5
Parameters
power to raise this BigDecimal to.
Throws
if n is out of range.
Returns a BigDecimal whose value is (this<sup>n</sup>). The current implementation uses the core algorithm defined in ANSI standard X3.274-1996 with rounding according to the context settings. In general, the returned numerical value is within two ulps of the exact numerical value for the chosen _precision. Note that future releases may use a different algorithm with a decreased allowable error bound and increased allowable exponent range.
The X3.274-1996 algorithm is:
An
ArithmeticExceptionexception is thrown ifabsoluteValue(n) > 999999999mc._precision == 0andn < 0mc._precision > 0andnhas more thanmc._precisiondecimal digits
if
nis zero, BigDecimal.ONE is returned even ifthisis zero, otherwiseif
nis positive, the result is calculated via the repeated squaring technique into a single accumulator. The individual multiplications with the accumulator use the same math context settings as inmcexcept for a _precision increased tomc._precision + elength + 1whereelengthis the number of decimal digits inn.if
nis negative, the result is calculated as ifnwere positive; this value is then divided into one using the working _precision specified above.The final value from either the positive or negative case is then rounded to the destination _precision.
Return
this<sup>n</sup> using the ANSI standard X3.274-1996 algorithm
Since
1.5
Parameters
power to raise this BigDecimal to.
the context to use.
Throws
if the result is inexact but the rounding mode is UNNECESSARY, or n is out of range.