From d5d6e9f8b68e27fbdf75a8b6a91327856ab30340 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20A=2E=20Holm?= Date: Wed, 22 Feb 2023 14:03:05 +0100 Subject: [PATCH] hum, si, sj: Use `--round=nearest` with `numfmt`(1) Default behavior is to round away from zero, that can be annoying if the number for example is 1G+1, then it will round it up to 2G. It also fixes rounding errors, for example would echo 1.07G | si display the value 1070000001. See the log message for commit `094a1e9e275d` ("Local/s10/mob: Fix rounding errors, use `--round=nearest` in `numfmt`(1)", 2021-05-24) for more info about this problem. e501202c-b2b2-11ed-bb36-5582e081d110 --- hum | 4 ++-- si | 4 ++-- sj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hum b/hum index 6c99933a..a4783474 100755 --- a/hum +++ b/hum @@ -8,8 +8,8 @@ #============================================================================== progname=hum -VERSION=0.1.1 +VERSION=0.1.2 -numfmt --to=si --format=%7.2f --invalid=ignore "$@" +numfmt --to=si --format=%7.2f --invalid=ignore --round=nearest "$@" # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 : diff --git a/si b/si index c244649e..d28f9522 100755 --- a/si +++ b/si @@ -6,8 +6,8 @@ #============================================================================== progname=si -VERSION=0.1.0 +VERSION=0.1.1 -numfmt --from=auto "$@" +numfmt --from=auto --round=nearest "$@" # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 : diff --git a/sj b/sj index 5434023a..39722739 100755 --- a/sj +++ b/sj @@ -11,7 +11,7 @@ #======================================================================= progname=sj -VERSION=0.8.6 +VERSION=0.8.7 ARGS="$(getopt -o "\ h\ @@ -104,7 +104,7 @@ END exit 0 fi -space_val="$(numfmt --from=auto -- $opt_space)" +space_val="$(numfmt --from=auto --round=nearest -- $opt_space)" test -z "$space_val" && { echo "$progname: Invalid value in --space argument" >&2 exit 1 -- 2.11.4.GIT