code

function toThousands(num) {
if (isNaN(num) || num == undefined || num == null || num == "") {
return "";
}
num = num.toString();
var numArr = num.split('.');
num = numArr[0];
var result = '';
while (num.length > 3) {
result = ',' + num.slice(-3) + result;
num = num.slice(0, num.length - 3);
}
if (num) { result = num + result; }
return result + '.' + numArr[1];
}

//四舍五入保留两位小数

var ta = (Math.round(6.327 * 100) / 100).toFixed(2);
C#:var grossWt = Math.Round(grossWt, 3, MidpointRounding.AwayFromZero);

posted on 2019-01-10 18:36  邢帅杰  阅读(454)  评论(0编辑  收藏  举报