summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-09-21 16:17:39 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-09-21 16:17:39 +0000
commitc5a6160798f51500212e5325250265d3a511e118 (patch)
treec4a95fa38fe2d606381cad8bb88fd3ddaa917ab3 /perl-install
parent1911b93aecc2910912c2dd503a23cd8e6b61a0b8 (diff)
downloaddrakx-backup-do-not-use-c5a6160798f51500212e5325250265d3a511e118.tar
drakx-backup-do-not-use-c5a6160798f51500212e5325250265d3a511e118.tar.gz
drakx-backup-do-not-use-c5a6160798f51500212e5325250265d3a511e118.tar.bz2
drakx-backup-do-not-use-c5a6160798f51500212e5325250265d3a511e118.tar.xz
drakx-backup-do-not-use-c5a6160798f51500212e5325250265d3a511e118.zip
simplify handling negative numbers
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/common.pm8
1 files changed, 5 insertions, 3 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index cb040772a..452e9ab37 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -131,22 +131,24 @@ sub removeXiBSuffix {
sub formatXiB {
my ($newnb, $o_newbase) = @_;
my $newbase = $o_newbase || 1;
+ my $sign = $newnb < 0 ? -1 : 1;
+ $newnb = abs($newnb);
my ($nb, $base);
my $decr = sub {
($nb, $base) = ($newnb, $newbase);
- abs($base) >= 1024 ? ($newbase = $base / 1024) : ($newnb = $nb / 1024);
+ $base >= 1024 ? ($newbase = $base / 1024) : ($newnb = $nb / 1024);
};
my $suffix;
foreach (N("B"), N("KB"), N("MB"), N("GB"), N("TB")) {
$decr->();
- if (abs($newnb) < 1 && abs($newnb * $newbase) < 1) {
+ if ($newnb < 1 && $newnb * $newbase < 1) {
$suffix = $_;
last;
}
}
my $v = $nb * $base;
my $s = $v < 10 && int(10 * $v - 10 * int($v));
- int($v) . ($s ? "." . abs($s) : '') . ($suffix || N("TB"));
+ int($v * $sign) . ($s ? "." . abs($s) : '') . ($suffix || N("TB"));
}
sub formatTime {