]> git.saurik.com Git - apple/libc.git/blobdiff - gdtoa/FreeBSD/gdtoa-gdtoa.c
Libc-594.9.5.tar.gz
[apple/libc.git] / gdtoa / FreeBSD / gdtoa-gdtoa.c
index 706c055d62e5a75ec2496ddab3abde048cc2f991..3b642508fe93b5caf8b926e9a7af45d1c363727d 100644 (file)
@@ -26,14 +26,8 @@ THIS SOFTWARE.
 
 ****************************************************************/
 
-/* Please send bug reports to
-       David M. Gay
-       Bell Laboratories, Room 2C-463
-       600 Mountain Avenue
-       Murray Hill, NJ 07974-0636
-       U.S.A.
-       dmg@bell-labs.com
- */
+/* Please send bug reports to David M. Gay (dmg at acm dot org,
+ * with " at " changed at "@" and " dot " changed to ".").     */
 
 #include "gdtoaimp.h"
 
@@ -83,7 +77,7 @@ bitstob(ULong *bits, int nbits, int *bbits)
 /* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
  *
  * Inspired by "How to Print Floating-Point Numbers Accurately" by
- * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
+ * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
  *
  * Modifications:
  *     1. Rather than iterating, we use a simple numeric overestimate
@@ -423,11 +417,9 @@ gdtoa
                                        if (dval(d) > ds + dval(eps))
                                                goto bump_up;
                                        else if (dval(d) < ds - dval(eps)) {
-                                               while(*--s == '0'){}
-                                               s++;
                                                if (dval(d))
                                                        inex = STRTOG_Inexlo;
-                                               goto ret1;
+                                               goto clear_trailing0;
                                                }
                                        break;
                                        }
@@ -485,8 +477,12 @@ gdtoa
                                                        }
                                        ++*s++;
                                        }
-                               else
+                               else {
                                        inex = STRTOG_Inexlo;
+ clear_trailing0:
+                                       while(*--s == '0'){}
+                                       ++s;
+                                       }
                                break;
                                }
                        }
@@ -744,7 +740,7 @@ gdtoa
                if (b->wds > 1 || b->x[0])
                        inex = STRTOG_Inexlo;
                while(*--s == '0'){}
-               s++;
+               ++s;
                }
  ret:
        Bfree(S);