bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] ftoastr: new module, for lossless conversion of floats to sh


From: Paul Eggert
Subject: Re: [PATCH] ftoastr: new module, for lossless conversion of floats to short strings
Date: Thu, 18 Nov 2010 21:36:27 -0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6

I tried making it not depend on snprintf, and it wasn't worth the extra
complexity.  So I followed your suggestions instead, and pushed the following.
Thanks again for your comments.

>From d61495a69d1174f41ec8d91d429277c56e46cced Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Thu, 18 Nov 2010 21:30:29 -0800
Subject: [PATCH] ftoastr: depend on snprintf, improve comments

* lib/ftoastr.c: Also mention Loitsch's draft.
* lib/ftoastr.h: Require WIDTH to be nonnegative.  This isn't
needed in the current implementation, but it might simplify
speeding up the code later.
* modules/ftoastr: Depend on snprintf; this improves portability.
Suggested by Bruno Haible in the same email.
---
 ChangeLog       |    8 ++++++++
 lib/ftoastr.c   |    3 ++-
 lib/ftoastr.h   |    4 ++--
 modules/ftoastr |    1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a1043bd..217fbba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-11-18  Paul Eggert  <address@hidden>
 
+       ftoastr: depend on snprintf, improve comments
+       * lib/ftoastr.c: Also mention Loitsch's draft.
+       * lib/ftoastr.h: Require WIDTH to be nonnegative.  This isn't
+       needed in the current implementation, but it might simplify
+       speeding up the code later.
+       * modules/ftoastr: Depend on snprintf; this improves portability.
+       Suggested by Bruno Haible in the same email.
+
        ftoastr: port to hosts lacking strtof and strtold
        Problem reported by Bruno Haible in
        <http://lists.gnu.org/archive/html/bug-gnulib/2010-11/msg00242.html>.
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index ddc5251..f747400 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -64,7 +64,8 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, 
FLOAT x)
 
      Florian Loitsch, Printing floating-point numbers quickly and accurately
      with integers.  ACM SIGPLAN notices 46, 6 (June 2010), 233-243
-     <http://dx.doi.org/10.1145/1809028.1806623>.  */
+     <http://dx.doi.org/10.1145/1809028.1806623>; also see the
+     2010-03-21 draft <http://florian.loitsch.com/tmp/article.pdf>.  */
 
   char format[sizeof "%-+ 0*.*Lg"];
   FLOAT abs_x = x < 0 ? -x : x;
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
index 4c4f890..fd7a802 100644
--- a/lib/ftoastr.h
+++ b/lib/ftoastr.h
@@ -26,8 +26,8 @@
 /* Store into BUF (of size BUFSIZE) an accurate minimal-precision
    string representation of a floating point number.  FLAGS affect the
    formatting of the number.  Pad the output string with spaces as
-   necessary to width WIDTH bytes, in the style of printf.  X is the
-   floating-point number to be converted.
+   necessary to width WIDTH bytes, in the style of printf.  WIDTH must
+   be nonnegative.  X is the floating-point number to be converted.
 
    Return the number of bytes stored into BUF, not counting the
    terminating null.  However, do not overrun BUF: if BUF is too
diff --git a/modules/ftoastr b/modules/ftoastr
index 64d0a77..862fb1a 100644
--- a/modules/ftoastr
+++ b/modules/ftoastr
@@ -10,6 +10,7 @@ m4/c-strtod.m4
 
 Depends-on:
 intprops
+snprintf
 
 configure.ac:
 AC_REQUIRE([gl_C99_STRTOLD])
-- 
1.7.2




reply via email to

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