Closed blake256 closed 2 years ago
One of the reasons APIs like BigNumber
exist is to avoid the problems of the native JavaScript number type, which you've provided as input.
To fix it, use a string instead:
new BigNumber('1.111111111111111111').shiftedBy(18).toFixed()
// "1111111111111111111"
One of the reasons APIs like
BigNumber
exist is to avoid the problems of the native JavaScript number type, which you've provided as input.To fix it, use a string instead:
new BigNumber('1.111111111111111111').shiftedBy(18).toFixed() // "1111111111111111111"
Good point, thank you very much ser!
Hello @MikeMcl
I'm not sure if this is intended behavior or not but the following conversion returns an unexpected value:
new BigNumber(1.111111111111111111).shiftedBy(18).toFixed()
1111111111111111200
= actual1111111111111111111
= expectedshiftedBy(18)
is the same astimes(new BigNumber(10).pow(18))
correct?