fix previous commit :)

git-svn-id: http://www.observium.org/svn/observer/trunk@2759 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-12-06 22:26:47 +00:00
parent a1e96f708f
commit 70f51cef04
5 changed files with 15 additions and 9 deletions

View File

@@ -475,12 +475,18 @@ function format_si($rate, $round = 2)
return round($rate, $round).$ext;
}
function format_bi($size, $round = '2')
function format_bi($value, $round = '2')
{
if($value < "0")
{
$neg = 1;
$value = $value * -1;
}
$sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E');
$ext = $sizes[0];
for ($i = 1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; }
return round($size, $round).$ext;
for ($i = 1; (($i < count($sizes)) && ($value >= 1024)); $i++) { $value = $value / 1024; $ext = $sizes[$i]; }
if($neg) { $value = $value * -1; }
return round($value, $round).$ext;
}
function format_number($value, $base = '1000', $round=2)