diff --git a/src/ChangeLog b/src/ChangeLog index a52c9bbb..97773421 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-06-25 Hrvoje Niksic + + * utils.c (human_readable): Divide with 1024 instead of shifting + so the operation can work with non-integer N. + 2005-06-25 Hrvoje Niksic * progress.c (eta_to_human): New logic for more human-readable diff --git a/src/utils.c b/src/utils.c index a2942b37..9eea3a4e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1275,11 +1275,11 @@ human_readable (wgint n) /* At each iteration N is greater than the *subsequent* power. That way N/1024.0 produces a decimal number in the units of *this* power. */ - if ((n >> 10) < 1024 || i == countof (powers) - 1) + if ((n / 1024) < 1024 || i == countof (powers) - 1) { /* Must cast to long first because MS VC can't directly cast __int64 to double. (This is safe because N is known to - be <2**20.) */ + be < 1024^2, so always fits into long.) */ double val = (double) (long) n / 1024.0; /* Print values smaller than 10 with one decimal digits, and others without any decimals. */ @@ -1287,7 +1287,7 @@ human_readable (wgint n) val < 10 ? 1 : 0, val, powers[i]); return buf; } - n >>= 10; + n /= 1024; } return NULL; /* unreached */ }