(human_readable): Fix bug that rounded 10501 to 10k.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 3 Sep 2003 19:57:54 +0000 (19:57 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 3 Sep 2003 19:57:54 +0000 (19:57 +0000)
Bug reported by Lute Kamstra in
<http://mail.gnu.org/archive/html/bug-gnulib/2003-09/msg00003.html>.

lib/ChangeLog
lib/human.c

index 3d9f379e0fdb12f956d8a33be82932f8119b2607..795d1ab3ed29150ff8067be76c569cd9869b3aea 100644 (file)
@@ -1,5 +1,9 @@
 2003-09-03  Paul Eggert  <eggert@twinsun.com>
 
+       * human.c (human_readable): Fix bug that rounded 10501 to 10k.
+       Bug reported by Lute Kamstra in
+       <http://mail.gnu.org/archive/html/bug-gnulib/2003-09/msg00003.html>.
+
        * getdate.y (relative_time_table): Use tDAY_UNIT for "tomorrow",
        "yesterday", "today", and "now" rather than tMINUTE_UNIT.  Of
        course with correspondingly smaller numbers for tomorrow and
index a838e8c41effe9f5f25760348a6e603160328a3f..285e4fd55e8c41bbdf11bf871cb0d09adc5e08d6 100644 (file)
@@ -355,11 +355,9 @@ human_readable (uintmax_t n, char *buf, int opts,
          }
       }
 
-    if (inexact_style == human_ceiling
-       ? 0 < tenths + rounding
-       : inexact_style == human_round_to_nearest
-       ? 5 < tenths + (2 < rounding + (amt & 1))
-       : /* inexact_style == human_floor */ 0)
+    if (inexact_style == human_round_to_nearest
+       ? 5 < tenths + (0 < rounding + (amt & 1))
+       : inexact_style == human_ceiling && 0 < tenths + rounding)
       {
        amt++;