about summary refs log tree commit diff
path: root/stdio-common/printf_fp.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/printf_fp.c')
-rw-r--r--stdio-common/printf_fp.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 5cf60f131c..009bdee0d5 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -625,11 +625,22 @@ __printf_fp (FILE *fp,
       /* All factors but 10^-1 are tested now.	*/
       if (exponent > 0)
 	{
+	  int cnt_l;
+
 	  cy = __mpn_mul_1 (tmp, frac, fracsize, 10);
 	  tmpsize = fracsize;
 	  assert (cy == 0 || tmp[tmpsize - 1] < 20);
 
-	  (void) __mpn_rshift (frac, tmp, tmpsize, MIN (4, exponent));
+	  count_trailing_zeros (cnt_l, tmp[0]);
+	  if (cnt_l < MIN (4, exponent))
+	    {
+	      cy = __mpn_lshift (frac, tmp, tmpsize,
+				 BITS_PER_MP_LIMB - MIN (4, exponent));
+	      if (cy != 0)
+		frac[tmpsize++] = cy;
+	    }
+	  else
+	    (void) __mpn_rshift (frac, tmp, tmpsize, MIN (4, exponent));
 	  fracsize = tmpsize;
 	  exp10 |= 1;
 	  assert (frac[fracsize - 1] < 10);