diff --git a/luna/Units.cpp b/luna/Units.cpp index 98eb4e70..1ce0208c 100644 --- a/luna/Units.cpp +++ b/luna/Units.cpp @@ -1,15 +1,14 @@ #include #include -#include Result to_dynamic_unit(usize value, char* buffer, size_t max) { if (value < 1024) { return string_format(buffer, max, "%u bytes", value); } const char* unit_prefixes = "KMGTPE"; - for (int i = 40; i >= 0 && value > (0xfffccccccccccccUL >> i); i -= 10) + while (value > (1024 * 1024)) { - value >>= 10; + value /= 1024; unit_prefixes++; }