Skip to content

Commit 72b0429

Browse files
author
Pascal Dreissen
committed
Create a consistent bytes format output through all lists
1 parent 229ef65 commit 72b0429

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,14 @@ public function intval($string, $force_numeric = false) {
281281
* @return string - formated bytes
282282
*/
283283
public function formatBytes($size, $precision = 2) {
284-
$base=log($size)/log(1024);
285284
$suffixes=array('', ' kB', ' MB', ' GB', ' TB');
286-
return round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)];
285+
if($size != 0 || is_nan($size)) {
286+
$base=log($size)/log(1024);
287+
$tmpoutput = round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)];
288+
} else {
289+
$tmpoutput = "0 " . $suffixes[1];
290+
}
291+
return $tmpoutput;
287292
}
288293

289294
/** IDN converter wrapper.

0 commit comments

Comments
 (0)