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

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

Deno / TypeScript to Ethereum Connector
Latest
method BigNumber.prototype.modulo
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 modulo n, i.e. the integer remainder of dividing this BigNumber by n.

The value returned, and in particular its sign, is dependent on the value of the MODULO_MODE setting of this BigNumber constructor. If it is 1 (default value), the result will have the same sign as this BigNumber, and it will match that of Javascript's % operator (within the limits of double precision) and BigDecimal's remainder method.

The return value is always exact and unrounded.

See MODULO_MODE for a description of the other modulo modes.

1 % 0.9                         // 0.09999999999999998
x = new BigNumber(1)
x.modulo(0.9)                   // '0.1'
y = new BigNumber(33)
y.modulo('a', 33)               // '3'

Parameters

n: BigNumber.Value

A numeric value.

optional
base: number