js四舍五入

用X.toFixed(2)是5舍6入的,

function xround(x, num){
return Math.round(x * Math.pow(10, num)) / Math.pow(10, num) ;
}

xround(X,2)这样才是四舍五入

原文地址:https://www.cnblogs.com/xiaolaipi/p/7204871.html