JS格式化数字成逗号分隔&JS四舍五入
//将数字格式化成逗号分隔的形式 function formatSplitNum(num) { if(!/^(\+|-)?(\d+)(\.\d+)?$/.test(num)){ return num; } var a = RegExp.$1, b = RegExp.$2, c = RegExp.$3; var re = new RegExp().compile("(\\d)(\\d{3})(,|$)"); while(re.test(b)) b = b.replace(re, "$1,$2$3"); return a +""+ b +""+ c; } //四舍五入函数 new Number(sumValue).toFixed(precision);