[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7436: [PATCH] ftoastr: new module, for lossless conversion of floats
bug#7436: [PATCH] ftoastr: new module, for lossless conversion of floats to short strings
Thu, 18 Nov 2010 09:35:20 -0800
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:18.104.22.168) Gecko/20101027 Thunderbird/3.0.10
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.
|[Prev in Thread]
||[Next in Thread]|
- bug#7436: [PATCH] ftoastr: new module, for lossless conversion of floats to short strings,
Paul Eggert <=