round partial sum to avoid floating point errors
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 13 Mar 2021 06:16:29 +0000 (07:16 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Apr 2022 09:04:29 +0000 (11:04 +0200)
Optional value available since commit v1.03-19-g0938debbad (2019-09-08)
[indicate limited results in stats] was overlooked while fixing formatting
in v1.06-24-g28f38df922 (2019-10-08) [round total value in statistics].

barcat
t/t2180-spark_combined_--spark=012345_-cs_--maxval=1_-L17.out

diff --git a/barcat b/barcat
index 319bc32826a65d60844f21a872dbefd2a8bef32e..0ab19d9c1159eb7349cf005cd52f0d6ebfc38e22 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -308,7 +308,7 @@ say $opt{palette} ? color(0) : '' if $opt{spark};
 
 sub show_stat {
        if ($opt{hidemin} or $opt{hidemax}) {
-               printf '%s of ', sum(grep { length }
+               printf '%.8g of ', sum(grep { length }
                        @values[$opt{hidemin} .. ($opt{hidemax} || @lines) - 1]
                ) // 0;
        }
index df1134e35ae53a5f97756952dacea29b870ad890..85a14465bac38380f29fa845b0afe17debb71c04 100644 (file)
@@ -1,2 +1,2 @@
 \e[31m1\e[90m2\e[90m3\e[90m3\e[90m0\e[90m4\e[90m4\e[90m3\e[90m4\e[90m4\e[90m3\e[90m4\e[32m4\e[32m50\e[32m4\e[90m3\e[0m
--7.4589999998 of \e[1m-7.459\e[0m total in 16 values over 18 lines (\e[31m-3\e[0m min, \e[36m-0.47\e[0m avg, \e[32m2\e[0m max)
+-7.459 of \e[1m-7.459\e[0m total in 16 values over 18 lines (\e[31m-3\e[0m min, \e[36m-0.47\e[0m avg, \e[32m2\e[0m max)