why Decimal('1.1249999999999999999').toNumber() is 1.125 and toFixed(2) is '1.12'
liubolp opened this issue · 4 comments
liubolp commented
MikeMcl commented
First, please explain to me how you set the precision of the division operation and what effect that has.
liubolp commented
Thank you for replying to my question, all my configurations are default. Decimal.precision is 20.
I want e.toFixed(2)=='1.13'
What should I do?
MikeMcl commented
What do you think is the effect of having precision set to 20? Look at the result of individual division and multiplication operations. I am not going to do the work for you.
liubolp commented
e.toDP(Decimail.precision - 1).toFixed(2)
Solved my problem!
Thank you!