bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gmp] Bug in mpf_get_str.


From: Torbjorn Granlund
Subject: Re: [Bug-gmp] Bug in mpf_get_str.
Date: 31 Jul 2000 01:43:16 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.6

wilco oelen <address@hidden> writes:

  The bug is fairly simple to describe. When the number 1 is printed,
  then it is printed as 0.9999999999..., even if the accuracy is much
  higher and the number is given precisely as 1.

Thanks for a good bug report.  This patch should fix that output
rounding bug.  Please try it and tell me how it works.

2000-07-31  Torbjorn Granlund  <address@hidden>

        * mpf/get_str.c: Develop three extra digits, not just one.

Index: mpf/get_str.c
===================================================================
RCS file: /home/cvsfiles/gmp/mpf/get_str.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -c -1 -r1.10 -r1.11
*** get_str.c   2000/07/24 17:04:19     1.10
--- get_str.c   2000/07/30 23:38:16     1.11
***************
*** 319,327 ****
  
    /* Allocate temporary digit space.  We can't put digits directly in the user
       area, since we generate more digits than requested.  (We allocate
!      BITS_PER_MP_LIMB + 1 extra bytes because of the digit block nature of the
       conversion.)  */
!   tstr = (unsigned char *) TMP_ALLOC (n_digits + BITS_PER_MP_LIMB + 1);
  
!   for (digits_computed_so_far = 0; digits_computed_so_far <= n_digits;
         digits_computed_so_far += dig_per_u)
--- 319,332 ----
  
+   /* Now that we have normalized the number, develop the digits, essentially 
by
+      multiplying it by BASE.  We initially develop at least 3 extra digits,
+      since the two leading digits might become zero, and we need one extra for
+      rounding the output properly.  */
+ 
    /* Allocate temporary digit space.  We can't put digits directly in the user
       area, since we generate more digits than requested.  (We allocate
!      BITS_PER_MP_LIMB extra bytes because of the digit block nature of the
       conversion.)  */
!   tstr = (unsigned char *) TMP_ALLOC (n_digits + BITS_PER_MP_LIMB + 3);
  
!   for (digits_computed_so_far = 0; digits_computed_so_far < n_digits + 3;
         digits_computed_so_far += dig_per_u)
   

-- 
Torbjörn


reply via email to

[Prev in Thread] Current Thread [Next in Thread]