js parseFloat 浮点数求和 精确位数

来源:互联网 发布:淘宝店铺导航在线制作 编辑:程序博客网 时间:2024/05/21 15:05

  $.each(xArr, function(i, n) {
                               totalZhi+=parseFloat(valueArr[i]);

}

 


              tbody+="<tr><td style='cursor:pointer;'>合计</td><td>" + totalZhi.toFixed(2) + "</td></tr>";
                     

精确到小数点后两位,如6622.00

没有使用toFixed(2)时,显示6621.999999999999