I have used Bignumber.js API for performing some JS calculations involving large numbers. I am performing a subtraction where the result should be 0
but the output is like -0.00000000000000000099
. How do I counter such issues with Bignumber API.
(new BigNumber(refinedGoal)).minus(monthlyReminder).toFixed()
gives -0.00000000000000000099
while using arithmetic subtraction operator
((new BigNumber(refinedGoal)) - monthlyReminder).toFixed()
gives 0
.
My overall goal is to save this result 0
in some JSON variable.
Edit 1:
The monthlyReminder.toFixed()
value is 1030.19999999999999999886
and refinedGoal
value is 1030.2