aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-11-19 12:05:48 +0100
committerFederico Angelilli <code@fedang.net>2024-11-19 12:05:48 +0100
commitb5cb61379978fa6dc8d6468dd2f8b412e58cf7bb (patch)
treefba4419cdbfa65391f1b044c9ff0a799eefc19bd /src/util.c
parentafcbe44a7cf454f3588a60180d93f65df9e5fcc7 (diff)
Add units to ram
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 714ce9d..b077484 100644
--- a/src/util.c
+++ b/src/util.c
@@ -200,11 +200,11 @@ int snprintf_units(char *buffer, size_t max, uint64_t bytes, unit_t unit)
break;
default: {
- int i = -1;
- do {
+ int i = 0;
+ while (round(value) >= base && i < 4) {
value /= base;
i++;
- } while (round(value * 10) / 10 >= base && i < 4);
+ }
const char *units[2][5] = {
{ " B", " kB", " MB", " GB", " TB" },