DEV Community


Posted on


BigNumber is an object which safely allows mathematical operations on numbers of any magnitude
uint256 has a range from 0 to (2^256) - 1. Therefore, the maximum number that can be held by the uint256 datatype is astronomically large.
Specifically, the maximum value for uint256 is:

In Javascript's number data type has a significantly smaller upper limit.
Specifically, the maximum value of a numeric type that Javascript can hold is just

If that number is greater than Javascript's maximum numeric value, which is quite definitely possible, then what happens?
Javascript can not support that. Therefore, we have to use a special type called a BigNumber.
ibraries used for interacting with Ethereum nodes - ethers.js and web3.js - both come with support for BigNumbers.

BigNumber is a custom class library, written in Javascript, that introduces it's own functions for mathematical functions - add, sub, mul, div, etc. BigNumber has a significantly larger capacity for numbers than what Javascript can natively support.

Top comments (0)