diff --git a/src/utils.c b/src/utils.c index 1050494..b47093f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -49,8 +49,7 @@ inline uint64_t timespec_diff_us(const struct timespec *a, const struct timespec } inline char *pretty_num(const double num, char *buf, const size_t bufsz) { - const uint8_t decimals = (num < 10) ? 2 : (num < 100) ? 1 - : 0; + const uint8_t decimals = (num <= 10) ? 2 : (num <= 100) ? 1 : 0; snprintf(buf, bufsz, "%.*f", decimals, num); return buf; } @@ -59,7 +58,7 @@ inline char *pretty_bytes(const uint64_t bytes, int8_t start_suffix, char *buf, const char suffix_list[] = {'K', 'M', 'G', 'T', 'P', 'E', 'Z'}; start_suffix *= -1; double bytes_d = (double)bytes; - while (bytes_d > 1024.0) { + while (bytes_d >= 1024.0) { bytes_d /= 1024.0; start_suffix++; }