From e420db389932e1a168073d3516fcd82587bba986 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 8 Sep 2019 16:44:39 +0200 Subject: [PATCH] fix sival log for negative/zero values --- barcat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barcat b/barcat index a664d0d..4846434 100755 --- a/barcat +++ b/barcat @@ -143,7 +143,7 @@ if ($opt{markers} // 1 and $size > 0) { @lines > $nr or return if $opt{hidemin}; sub sival { - my $unit = int(log($_[0]) / log(1000) - ($_[0] < 1) + 1e-15); + my $unit = int(log(abs $_[0] || 1) / log(1000) - ($_[0] < 1) + 1e-15); my $float = sprintf '%e', $_[0] / 1000 ** $unit; #TODO: or $_[0] =~ /\./ $float -= int($float); sprintf('%*.*f%*s', -- 2.30.0