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)

原文地址:https://www.cnblogs.com/webSong/p/9328608.html