toFixed(10)四舍五入为10的数字(舍弃了后面的一部分)
parseFloat((0.1 + 0.2).toFixed(10)) === 0.3 // true
console.log(0.100000000000000002) // 0.1
0.200000000000000002 === 0.2 // true
18位
toFixed(10)四舍五入为10的数字(舍弃了后面的一部分)
parseFloat((0.1 + 0.2).toFixed(10)) === 0.3 // true
console.log(0.100000000000000002) // 0.1
0.200000000000000002 === 0.2 // true
18位
本文标题:16,0.1 + 0.2 != 0.3
本文链接:https://www.haomeiwen.com/subject/caabtktx.html
网友评论