function nicenum($num, $treshold = 1024, $divider = 1024) { // display nicely formated number divided into correct units $r = 0; while ($num > $treshold) { $num /= $divider; $r++; } $rs = array("", "k", "M", "G"); $vysnew = niceround($num, 2); return $vysnew . " " . $rs[$r]; }
function showperc($part, $total, $decs = 2) { // show nicely formated percentage if ($total > 0) { $vys = round($part / $total * 100, $decs); if ($vys == 100 && $part < $total) { $vys -= 1 / (10 ^ $decs); } if ($vys == 0 && $part > 0) { $vys += 1 / (10 ^ $decs); } } else { $vys = 0; } $vysnew = niceround($vys, $decs); return $vysnew; }