小数乘法精确率处理

问题:

let str = '2.53';
let num = parseFloat(str) *100;

alert(num) -> 252.999999999

解决:

let str = '2.53'
let num = parseFloat(str *100).toFixed(2)
let num1 = parseFloat(str *100).toFixed(0)

alert(num) -> 253.00
alert(num1) -> 253

你可能感兴趣的:(小数乘法精确率处理)