Index: includes/batch.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/batch.inc,v
retrieving revision 1.18
diff -u -p -r1.18 batch.inc
--- includes/batch.inc	18 Jun 2008 03:36:23 -0000	1.18
+++ includes/batch.inc	18 Jun 2008 04:51:34 -0000
@@ -235,8 +235,19 @@ function _batch_process() {
       $progress_message = $old_set['progress_message'];
     }
 
-    $current    = $total - $remaining + $finished;
-    $percentage = $total ? floor($current / $total * 100) : 100;
+    // Output percentages using the correct number of decimal places so
+    // that we never print "100%" until we are finished, but we also never
+    // print more decimal places than are meaningful.
+    $current = $total - $remaining + $finished;
+    if (!$total) {
+      $percentage = 100;
+    }
+    else {
+      $significant_digits = strlen((string)($total - 1));
+      $decimal_places = $significant_digits < 2 ? 0 : $significant_digits - 2;
+      $percentage = sprintf('%01.' . $decimal_places . 'f', round($current / $total * 100, $decimal_places));
+    }
+
     $values = array(
       '@remaining'  => $remaining,
       '@total'      => $total,
