JavaScript保留两位小数

Math.round(0.6546 * 100) / 100

Math.round()四舍五入

优化版本:

((0.1 * 100 + 0.2 * 100) / 100).toFixed(2) === (Math.floor((0.1+0.2) * 1000) / 1000).toFixed(2)

posted @ 2018-07-18 13:12  宋宇  阅读(154)  评论(0编辑  收藏  举报