bignumber.js icon indicating copy to clipboard operation
bignumber.js copied to clipboard

Not able to calculate negative pow greater than 20

Open amitguptagwl opened this issue 6 years ago • 1 comments

I found that if the pow is -21, the library returns 0.

> BigNumber(10).pow( -20 ).toFixed()
"0.00000000000000000001"
> BigNumber(10).pow( -21 ).toFixed()
"0"

amitguptagwl avatar Dec 27 '18 03:12 amitguptagwl

I know this is old, but I'm putting this here in case somebody else runs into a similar problem.

BigNumber.Config.DECIMAL_PLACES defaults to 20, so anything below that gets rounded by BigNumber.ROUND_HALF_UP, which results in 0.

Nilotaviano avatar Jan 14 '22 23:01 Nilotaviano