=== modified file 'ChangeLog'
--- ChangeLog 2011-01-08 21:19:44 +0000
+++ ChangeLog 2011-01-09 01:18:39 +0000
@@ -1,3 +1,8 @@
+2011-01-09 Paul Eggert
+
+ Use gnulib ftoastr module.
+ * Makefile.in (GNULIB_MODULES): Add ftoastr. Remove dummy.
+
2011-01-08 Paul Eggert
Regenerate.
=== modified file 'Makefile.in'
--- Makefile.in 2011-01-08 21:02:38 +0000
+++ Makefile.in 2011-01-09 01:18:39 +0000
@@ -330,7 +330,7 @@
# Update modules from gnulib, for maintainers, who should have it in
# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
# as per $(gnulib_srcdir)/DEPENDENCIES.
-GNULIB_MODULES = dummy # Just a dummy for now, to establish the mechanism.
+GNULIB_MODULES = ftoastr
GNULIB_TOOL_FLAGS = \
--import --no-changelog --no-vc-files --makefile-name=gnulib.mk
sync-from-gnulib: $(gnulib_srcdir)
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2011-01-08 21:02:38 +0000
+++ src/ChangeLog 2011-01-09 01:18:39 +0000
@@ -1,3 +1,12 @@
+2011-01-09 Paul Eggert
+
+ Use gnulib's ftoastr module.
+ * print.c: Include ftoastr.h.
+ (FLT_RADIX, DBL_MANT_DIG, DBL_DIG, DBL_MIN, DOUBLE_DIGITS_BOUND):
+ Remove; no longer needed.
+ (float_to_string): Use dtoastr rather than rolling our own code,
+ which had an off-by-one bug on non-IEEE hosts.
+
2011-01-08 Paul Eggert
Automate syncing from gnulib.
=== modified file 'src/print.c'
--- src/print.c 2010-12-27 17:29:38 +0000
+++ src/print.c 2011-01-09 01:18:39 +0000
@@ -50,36 +50,12 @@
#if STDC_HEADERS
#include
#endif
+#include
/* Default to values appropriate for IEEE floating point. */
-#ifndef FLT_RADIX
-#define FLT_RADIX 2
-#endif
-#ifndef DBL_MANT_DIG
-#define DBL_MANT_DIG 53
-#endif
#ifndef DBL_DIG
#define DBL_DIG 15
#endif
-#ifndef DBL_MIN
-#define DBL_MIN 2.2250738585072014e-308
-#endif
-
-#ifdef DBL_MIN_REPLACEMENT
-#undef DBL_MIN
-#define DBL_MIN DBL_MIN_REPLACEMENT
-#endif
-
-/* Define DOUBLE_DIGITS_BOUND, an upper bound on the number of decimal digits
- needed to express a float without losing information.
- The general-case formula is valid for the usual case, IEEE floating point,
- but many compilers can't optimize the formula to an integer constant,
- so make a special case for it. */
-#if FLT_RADIX == 2 && DBL_MANT_DIG == 53
-#define DOUBLE_DIGITS_BOUND 17 /* IEEE floating point */
-#else
-#define DOUBLE_DIGITS_BOUND ((int) ceil (log10 (pow (FLT_RADIX, DBL_MANT_DIG))))
-#endif
/* Avoid actual stack overflow in print. */
int print_depth;
@@ -1125,19 +1101,8 @@
{
/* Generate the fewest number of digits that represent the
floating point value without losing information.
- The following method is simple but a bit slow.
- For ideas about speeding things up, please see:
-
- Guy L Steele Jr & Jon L White, How to print floating-point numbers
- accurately. SIGPLAN notices 25, 6 (June 1990), 112-126.
-
- Robert G Burger & R Kent Dybvig, Printing floating point numbers
- quickly and accurately, SIGPLAN notices 31, 5 (May 1996), 108-116. */
-
- width = fabs (data) < DBL_MIN ? 1 : DBL_DIG;
- do
- sprintf (buf, "%.*g", width, data);
- while (width++ < DOUBLE_DIGITS_BOUND && atof (buf) != data);
+ The 350 is by convention, e.g., this file's pigbuf. */
+ dtoastr (buf, 350, 0, 0, data);
}
else /* oink oink */
{