-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Keep in mind BigNumber is for integers, so it must have 0 decimals. It looks like you are trying to parse a decimal value into an integer quality, so you probably want If you are trying to later do math with it and maintain its precision, you will need to use the fixed-point math; Does that make sense? |
Beta Was this translation helpful? Give feedback.
Keep in mind BigNumber is for integers, so it must have 0 decimals.
It looks like you are trying to parse a decimal value into an integer quality, so you probably want
ethers.utils.parseUnits(coin.usd_exchange_rate, 8)
, if it will always be 8 decimals.If you are trying to later do math with it and maintain its precision, you will need to use the fixed-point math;
const value = ethers.FixedNumber.from(coin.usd_exchange_rate)
, which will by default usefixed128x18
for any operations on it, which should be enough for most peoples purposes.Does that make sense?