
获得徽章 0
- 张鑫旭发布的10年程序员心路历程的文章,很多地方都值得一个晚辈推敲和思考,从中也能够找到一点参考和方向。
文章地址如下:1点赞 - 0.1+0.2==0.3 可以使用Math.abs(0.1+0.2-0.3)<=Number.EPSILON解决,
也可以使用:
[math.js](mathjs.org网页链接网页链接网页链接)库解决
math.js的demo:
console.log(0.1 + 0.2 === 0.3) // false
console.log(math.equal(0.1 + 0.2, 0.3)) // true展开等人赞过219 - 0.1+0.2==0.3 可以使用Math.abs(0.1+0.2-0.3)<=Number.EPSILON解决,
也可以使用:
[math.js](mathjs.org网页链接网页链接)库解决
math.js的demo:
console.log(0.1 + 0.2 === 0.3) // false
console.log(math.equal(0.1 + 0.2, 0.3)) // true展开评论点赞