import { BigNumber } from "https://deno.land/x/web3@v0.11.1/types/bignumber.d.ts";
Returns a BigNumber whose value is the value of this BigNumber exponentiated by n
, i.e.
raised to the power n
, and optionally modulo a modulus m
.
If n
is negative the result is rounded according to the current DECIMAL_PLACES
and
ROUNDING_MODE
settings.
As the number of digits of the result of the power operation can grow so large so quickly,
e.g. 123.456**10000 has over 50000 digits, the number of significant digits calculated is
limited to the value of the POW_PRECISION
setting (unless a modulus m
is specified).
By default POW_PRECISION
is set to 0. This means that an unlimited number of significant
digits will be calculated, and that the method's performance will decrease dramatically for
larger exponents.
If m
is specified and the value of m
, n
and this BigNumber are integers and n
is
positive, then a fast modular exponentiation algorithm is used, otherwise the operation will
be performed as x.exponentiatedBy(n).modulo(m)
with a POW_PRECISION
of 0.
Throws if n
is not an integer.
Math.pow(0.7, 2) // 0.48999999999999994
x = new BigNumber(0.7)
x.exponentiatedBy(2) // '0.49'
BigNumber(3).exponentiatedBy(-2) // '0.11111111111111111111'