From: Mischa POSLAWSKY Date: Sun, 6 Oct 2019 23:51:05 +0000 (+0200) Subject: round total value slightly in statistics X-Git-Tag: v1.07~22 X-Git-Url: http://git.shiar.net/barcat.git/commitdiff_plain/4820a5300d409142bc5a3fec59006e3a96ea59df round total value slightly in statistics Compensate for cumulative floating point errors showing up. --- diff --git a/barcat b/barcat index 5676228..424bec2 100755 --- a/barcat +++ b/barcat @@ -277,7 +277,7 @@ sub show_stat { } if (@order) { my $total = sum @order; - printf '%s total', color(1) . $total . color(0); + printf '%s total', color(1) . sprintf('%.8g', $total) . color(0); printf ' in %d values', scalar @order; printf ' over %d lines', scalar @lines if @order != @lines; printf(' (%s min, %s avg, %s max)', diff --git a/t/t1312-currency-crop_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-s.out b/t/t1312-currency-crop_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-s.out index e89c5cc..d188c03 100644 --- a/t/t1312-currency-crop_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-s.out +++ b/t/t1312-currency-crop_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-s.out @@ -19,4 +19,4 @@ 2019-08-22 1.1083 ------------------ 2019-08-21 1.1104 ----------------------- 2019-08-20 1.1076 ----------------- -23.1939 of 6386.71270000003 total in 5306 values over 5373 lines (0.8252 min, 1.20 avg, 1.5990 max) +23.1939 of 6386.7127 total in 5306 values over 5373 lines (0.8252 min, 1.20 avg, 1.5990 max) diff --git a/t/t1602-float_statistics_-sL0.out b/t/t1602-float_statistics_-sL0.out index e067ae3..29557a1 100644 --- a/t/t1602-float_statistics_-sL0.out +++ b/t/t1602-float_statistics_-sL0.out @@ -1 +1 @@ --7.4589999998 total in 16 values over 18 lines (-3 min, -0.47 avg, 2 max) +-7.459 total in 16 values over 18 lines (-3 min, -0.47 avg, 2 max) diff --git a/t/t1901-technicolor_-cs_--header.out b/t/t1901-technicolor_-cs_--header.out index 415ea16..8c68b2d 100644 --- a/t/t1901-technicolor_-cs_--header.out +++ b/t/t1901-technicolor_-cs_--header.out @@ -17,4 +17,4 @@  1-2 -------<--=-|-----  -2.0 ---- --1 -------<--=-| --7.4589999998 total in 16 values over 18 lines (-3 min, -0.47 avg, 2 max) +-7.459 total in 16 values over 18 lines (-3 min, -0.47 avg, 2 max) diff --git a/t/t1912-currency_part_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-cs.out b/t/t1912-currency_part_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-cs.out index 4ae6263..f7598dd 100644 --- a/t/t1912-currency_part_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-cs.out +++ b/t/t1912-currency_part_-f,_--value-length=7_--minval=1.1_--maxval=1.11_-L10-30_-cs.out @@ -19,4 +19,4 @@ 2019-08-22 1.1083 ------------------ 2019-08-21 1.1104 ----------------------- 2019-08-20 1.1076 ----------------- -23.1939 of 6386.71270000003 total in 5306 values over 5373 lines (0.8252 min, 1.20 avg, 1.5990 max) +23.1939 of 6386.7127 total in 5306 values over 5373 lines (0.8252 min, 1.20 avg, 1.5990 max)