标签:
##format big number #macro (util_formatBigNumber $bigNumber) #set($intBigNumber = $mathTool.toNumber($bigNumber)) #if(!$intBigNumber) #set($intBigNumber = 0) #end #if ($intBigNumber >= 10000 && $intBigNumber < 100000000) #set($value = $mathTool.div($intBigNumber, 10000)) $numberTool.format(‘#0.0‘, $value)万## #elseif($intBigNumber >= 100000000) #set($value = $mathTool.div($intBigNumber, 100000000)) $numberTool.format(‘#0.0‘, $value)亿 #else $intBigNumber## #end #end ##format big money, like 1000 to 1,000 #macro (util_formatBigMoney $bigNumber) #set($intBigNumber = $mathTool.toNumber($bigNumber)) #if(!$intBigNumber) #set($intBigNumber = 0) #end #if ($intBigNumber >= 1000) $numberTool.format(‘#0,000‘, $intBigNumber) #else $intBigNumber## #end #end
js处理
function formateNumber(value) { var num = parseInt(value); if (num >= 10000 && num < 100000000) { var snum = (num / 10000).toFixed(1); // alert(snum); return snum + ‘万‘; } else if (num >= 100000000) { var snum = (num / 100000000).toFixed(1); return snum + ‘亿‘; } else { return num; } }; /*调整数字格式,100000变为100,000*/ function formatMoney(s) { s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(0) + ""; var l = s.split(".")[0].split("").reverse(), t = ""; for (i = 0; i < l.length; i++) { t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : ""); } return t.split("").reverse().join(""); }
标签:
原文地址:http://www.cnblogs.com/wangjb/p/5691052.html