GNU bug report logs - #7436
[PATCH] ftoastr: new module, for lossless conversion of floats to short strings

Previous Next

Package: coreutils;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Thu, 18 Nov 2010 17:31:02 UTC

Severity: normal

Tags: patch

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Jim Meyering <jim <at> meyering.net>
Cc: 7436 <at> debbugs.gnu.org, bug-gnulib <at> gnu.org
Subject: bug#7436: [PATCH] ftoastr: new module, for lossless conversion of floats to short strings
Date: Thu, 18 Nov 2010 09:35:20 -0800
On 11/18/10 08:36, Jim Meyering wrote:
> Before I'd looked through the code I started thinking this might
> be useful in avoiding snprintf's unhealthy need to malloc.
> Then I saw that it uses snprintf.  Oh well ;-)

There's a comment on how to fix that, for the common cases of
double on float on hosts with IEEE floating point and 64-bit ints.
It's a paper published earlier this year by Florian Loitsch
<http://dx.doi.org/10.1145/1809028.1806623>.  Not only would
this fix the malloc problem, it would run rings around sprintf,
performance-wise, on all libc implementations that I know of
that print floating-point numbers accurately.

The idea behind the latest checkin has been in Emacs for years, but the
immediate prompt for it was a bug that I found in coreutils
od, when I attempted to use it to generate floating point
numbers at random (by reading /dev/urandom).  The generated numbers
turned out to be non-random, and I tracked it down to a bug
in od.  I'll check in a fix to coreutils shortly.




This bug report was last modified 14 years and 94 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.