作者:涵涵 | 2021-08-11 00:24:06
复制代码 代码如下:
///计算两个整数的百分比值
function GetPercent(num, total) {
num = parseFloat(num);
total = parseFloat(total);
if (isNaN(num) || isNaN(total)) {
return "-";
}
return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00 + "%");
}