JavaScript以万或亿为单位显示,并保留两位小数或取整

//单位:万


n = 814308678.00;
n = Math.floor((n /10000) * 100) / 100; //保留小数点两位
//n = parseInt((n /10000) * 100 / 100); //取整
n = n + "万";

结果:
//81430.86万
//81430万


//单位:亿
n = 814308678.00;
n = Math.floor((n /100000000) * 100) / 100; //保留小数点两位
//n = parseInt((n /1000000000) * 100 / 100);// 取整
n = n + "亿";

结果:
//8.14亿
//8亿

原文地址:https://www.cnblogs.com/pengyczjg/p/13673374.html