commit 6660f7c537c5e03da23cca6fdfb2ca987155f2e1
parent 86c7a84c2397e5bbdcebe2a06bada7ee48f0d480
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date: Sat, 20 May 2023 11:02:09 +0200
[nat] Improve prefixless human formatting
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/util.c b/util.c
@@ -114,6 +114,9 @@ fmt_human(uintmax_t num, int base)
return NULL;
}
+ if (num < (uintmax_t)base)
+ return bprintf("%d", (int)num);
+
scaled = num;
for (i = 0; i < prefixlen && scaled >= base; i++)
scaled /= base;