function roundTo(base,precision)
{
var m=Math.pow(10,precision);
var a=Math.round(base * m) / m;
return a;
}
例如:给定数字n=6.3241712,则用roundTo(n,0)得4,用roundTo(n,7)得到6.3241712
2022-04-18 14:13:47
function roundTo(base,precision)
{
var m=Math.pow(10,precision);
var a=Math.round(base * m) / m;
return a;
}
例如:给定数字n=6.3241712,则用roundTo(n,0)得4,用roundTo(n,7)得到6.3241712