Calculation of inexhaustible numbers is imprecise
Closed this issue · 2 comments
cinling commented
Calculation of inexhaustible numbers is imprecise
Expect:
let val
val = new BigNumber(1).dividedBy(1760)
val = val.multipliedBy(1760)
console.log(val) // val = 1
Actual:
let val
val = new BigNumber(1).dividedBy(1760)
val = val.multipliedBy(1760)
console.log(val) // val = 0.9999999999999999968
MikeMcl commented
To see the value you are multiplying by 1760, try
val = new BigNumber(1).dividedBy(1760);
console.log(val.toString());
Then repeat it after entering say
BigNumber.set({ DECIMAL_PLACES: 40 });
cinling commented
这是来自QQ邮箱的假期自动回复邮件。
我也许不在,但我回尽快回复你的