日期:2014-05-18 浏览次数:20479 次
(function() { var As ={ //格式化数字 AsNumber.prototype.FormatNumberValue = function(precision) { var numberValue = this.value.toString(); var nArr = numberValue.split("."); var reg = /^[-]?[\d]+$/gim; if (!reg.test(nArr[0].toString())) { return NaN; } if (nArr.length > 1) { reg = /[^\d]/gim; if (reg.test(nArr[1].toString())) { return NaN; } } numberValue = nArr[0].toString(); //精度 var nPrecision = parseInt(precision); if (!isNaN(nPrecision) && (nPrecision > 0)) { var decimalValue = (nArr.length > 1) ? nArr[1].toString() : ""; numberValue += this.FormatPrecision(decimalValue, nPrecision); } return numberValue; } }; })();
function aa(bb,precision){ var numberValue = bb.toString(); var nArr = numberValue.split("."); var reg = /^[-]?[\d]+$/gim; if (!reg.test(nArr[0].toString())) { return NaN; } if (nArr.length > 1) { reg = /[^\d]/gim; if (reg.test(nArr[1].toString())) { return NaN; } } numberValue = nArr[0].toString(); //精度 var nPrecision = parseInt(precision); if (!isNaN(nPrecision) && (nPrecision > 0)) { var decimalValue = (nArr.length > 1) ? nArr[1].toString() : ""; numberValue += aa(decimalValue, nPrecision); } return numberValue; }