]> sjero.net Git - wget/commitdiff
[svn] Divide with 1024 instead of shifting by ten places.
authorhniksic <devnull@localhost>
Sat, 25 Jun 2005 21:16:51 +0000 (14:16 -0700)
committerhniksic <devnull@localhost>
Sat, 25 Jun 2005 21:16:51 +0000 (14:16 -0700)
src/ChangeLog
src/utils.c

index a52c9bbb7334f8d4e8405990f28d796dce98c209..97773421470e62a7e707570d0209c214c1245b76 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-25  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * utils.c (human_readable): Divide with 1024 instead of shifting
+       so the operation can work with non-integer N.
+
 2005-06-25  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * progress.c (eta_to_human): New logic for more human-readable
index a2942b3724c1e9f28598df4905a7ba947a0bfe12..9eea3a4e1d66429d5c13f99b7c70fc5ddfc5e694 100644 (file)
@@ -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 */
 }