mirror of https://github.com/schoebel/mars
marsadm: better human-readable units
This commit is contained in:
parent
b1dcc86784
commit
366711cee3
|
@ -3536,10 +3536,11 @@ sub number2human {
|
||||||
my ($number, $unit, $max) = @_;
|
my ($number, $unit, $max) = @_;
|
||||||
$max = $number if !defined($max);
|
$max = $number if !defined($max);
|
||||||
my $k = 1024.0;
|
my $k = 1024.0;
|
||||||
|
my $flip_over = 9.99;
|
||||||
if (!defined($unit) || !$unit) {
|
if (!defined($unit) || !$unit) {
|
||||||
if ($max >= $k * $k * $k * $k) {
|
if ($max >= $k * $k * $k * $k * $flip_over) {
|
||||||
$unit = "T";
|
$unit = "T";
|
||||||
} elsif ($max >= $k * $k * $k) {
|
} elsif ($max >= $k * $k * $k * $flip_over) {
|
||||||
$unit = "G";
|
$unit = "G";
|
||||||
} elsif ($max >= $k * $k) {
|
} elsif ($max >= $k * $k) {
|
||||||
$unit = "M";
|
$unit = "M";
|
||||||
|
|
Loading…
Reference in New Issue