JS中处理数字精度问题

const Bignumber = require('bignumber.js')

// 
console.log(`origin: 9.03*100=${9.03 * 100}`)

// 
console.log(`bignumber handle after: 9.03*100=${Bignumber(9.03).times(Bignumber(100))}`)

/**
 *  Result Console Log:
 * 
    origin: 9.03*100=902.9999999999999
    bignumber handle after: 9.03*100=903
 */

你可能感兴趣的:(javascript,前端,vue.js)