Mercurial > hg > octave-lyh > gnulib-hg
changeset 13879:608c8fdccab5
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.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 18 Nov 2010 21:30:29 -0800 |
parents | f120aacf676a |
children | fe3adfe381fa |
files | ChangeLog lib/ftoastr.c lib/ftoastr.h modules/ftoastr |
diffstat | 4 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-11-18 Paul Eggert <eggert@cs.ucla.edu> + 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>.
--- a/lib/ftoastr.c +++ b/lib/ftoastr.c @@ -64,7 +64,8 @@ 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;
--- 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