What are the meanings of the c
, e
, and s
fields in the object produced by bignumber.js
?
For example:
> new BigNumber('1234')
{ c: [1234], e: 3, s: 1 }
> new BigNumber('12345678901234567890')
{ c: [123456, 78901234567890], e: 19, s: 1 }
A BigNumber is an object which safely allows mathematical operations on numbers of any magnitude. Most operations which need to return a value will return a BigNumber and parameters which accept values will generally accept them.
Why would we use bignumber library? is it because it also works with decimals? Yes. A bignumber library typically works with arbitrary-precision floating-point numbers, while a bigint library (or also the builtin data type) can only handle integers.
Values in memory on the EVM are in 256 bit (32 byte) words - BigNumber s in this library are considered to be consecutive words in big-endian order (top to bottom: word 0 - word n ). The struct BigNumber defined in ( src/interfaces/IBigNumber ) consists of the bytes value, the bit-length, and the sign of the value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With