解决税额经常差一分的问题

4 阅读1分钟
106.95 * 72.1 // 7711.094999999999
(106.95 * 72.1).toFixed(2) // 7711.09
// 理想应该是7711.10
import * as mathjs from 'mathjs';
// 创建一个新的 math 实例并配置
const math = mathjs.create(mathjs.all, {
    number: 'BigNumber',
    precision: 14
});
Vue.prototype.$math = math;
window.$math = math;

this.$math.evaluate(`106.95 * 72.1`)).toFixed(2) // 正确 7711.10
this.$math.evaluate(`${item.taxAmount || 0} * ${item.bQty}`)).toFixed(2)