Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/web3/types/bignumber.d.ts>BigNumber#pow

Deno / TypeScript to Ethereum Connector
Latest
method BigNumber.prototype.pow
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.pow(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.pow(2)                           // '0.49'
BigNumber(3).pow(-2)               // '0.11111111111111111111'

Parameters

n: BigNumber.Value

The exponent, an integer.

optional
m: BigNumber.Value

Parameters

n: number
optional
m: BigNumber.Value