summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-01-09 15:28:44 -0700
committerJens Axboe <axboe@kernel.dk>2021-01-09 15:28:44 -0700
commit674428a527931d86bfb164abcc847508b3be2742 (patch)
treec3b6fb9f14ff2da133d70bbfc5f9d1769c775dad
parent8f14dc61422df3b1eaee1293a7d10ba791c8084c (diff)
parentc736b361190e1133b4d407a6c7615bf8c4d9c262 (diff)
downloadfio-674428a527931d86bfb164abcc847508b3be2742.tar.gz
fio-674428a527931d86bfb164abcc847508b3be2742.tar.bz2
Merge branch 'num2str-patch' of https://github.com/gloit042/fio
* 'num2str-patch' of https://github.com/gloit042/fio: num2str: fix precision loss bug when the fractional part is close to 1
-rw-r--r--lib/num2str.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/num2str.c b/lib/num2str.c
index 3597de2f..cd89a0e5 100644
--- a/lib/num2str.c
+++ b/lib/num2str.c
@@ -110,6 +110,9 @@ done:
sprintf(tmp, "%.*f", (int)(maxlen - strlen(tmp) - 1),
(double)modulo / (double)thousand);
+ if (tmp[0] == '1')
+ num++;
+
if (asprintf(&buf, "%llu.%s%s%s", (unsigned long long) num, &tmp[2],
unitprefix[post_index], unitstr[units]) < 0)
buf = NULL;