marsadm: better human-readable units

This commit is contained in:
Thomas Schoebel-Theuer 2018-07-18 10:19:19 +02:00
parent b1dcc86784
commit 366711cee3
1 changed files with 3 additions and 2 deletions

View File

@ -3536,10 +3536,11 @@ sub number2human {
my ($number, $unit, $max) = @_;
$max = $number if !defined($max);
my $k = 1024.0;
my $flip_over = 9.99;
if (!defined($unit) || !$unit) {
if ($max >= $k * $k * $k * $k) {
if ($max >= $k * $k * $k * $k * $flip_over) {
$unit = "T";
} elsif ($max >= $k * $k * $k) {
} elsif ($max >= $k * $k * $k * $flip_over) {
$unit = "G";
} elsif ($max >= $k * $k) {
$unit = "M";