From: Mischa POSLAWSKY Date: Sun, 8 Sep 2019 14:44:39 +0000 (+0200) Subject: fix sival log for negative/zero values X-Git-Tag: v1.05~18 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/e420db389932e1a168073d3516fcd82587bba986 fix sival log for negative/zero values --- 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',