1. 程式人生 > >js求兩個整數的百分比

js求兩個整數的百分比

function ota percent mat UNC cti float per round

function GetPercent(num, total) {
num = parseFloat(num);
total = parseFloat(total);
if (isNaN(num) || isNaN(total)) {
return "-";
}
return total <= 0 ? "0%" : (Math.round(num / total * 100) / 100.00);
}

js求兩個整數的百分比