print_percentage: Use floating point to avoid incorrect results when
authorPaul N. Hilfinger <hilfinger@adacore.com>
Sat, 20 Mar 2004 09:53:03 +0000 (09:53 +0000)
committerPaul N. Hilfinger <hilfinger@adacore.com>
Sat, 20 Mar 2004 09:53:03 +0000 (09:53 +0000)
 portion*100 overflows.

gdb/ChangeLog
gdb/bcache.c

index 442af68deab68065857a74a9436a674e3491134d..53824f1d941a2a2c8ddde8506d783a34de119766 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-20  Paul Hilfinger  <hilfingr@nile.gnat.com>
+
+       * bcache.c (print_percentage): Use floating point to avoid
+       incorrect results when portion*100 overflows.
+
 2004-03-19  Kevin Buettner  <kevinb@redhat.com>
 
        * ppc_tdep.h (ppc_linux_frame_saved_pc)
index cadadb5cce63f575591bd5ac0ca32c39259c8b0a..0bc533ebfefc35058f27dab49774eda6f98290ca 100644 (file)
@@ -303,7 +303,7 @@ print_percentage (int portion, int total)
   if (total == 0)
     printf_filtered ("(not applicable)\n");
   else
-    printf_filtered ("%3d%%\n", portion * 100 / total);
+    printf_filtered ("%3d%%\n", (int) (portion * 100.0 / total));
 }