[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?
- From: Tim Hill <drtimhill@...>
- Date: Tue, 10 Sep 2013 02:02:18 -0700
On Sep 10, 2013, at 1:51 AM, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Tue, Sep 10, 2013 at 10:44 AM, Tim Hill <drtimhill@gmail.com> wrote:
>> Wonderful.
>
> Absolutely. Wanting to serialize floats 'exactly' using strings is not
> the way to go. Integers (up to the 2^52 limit) are fine, and 5.3 gives
> us full (signed) 64-bit integer precision.
>
I'm also signing off here, but I want to make a couple of observations:
1. Serializing a float as a string is not, inherently, bad. Serializing it as a floating-point decimal literal string is, however, asking for trouble. There are plenty of string formats which provide perfect round-trip of IEEE-754 floats.
2. My point about tostring() was that "reasonable" is in the eye of the beholder. Is it reasonable to emit a float as an approximate decimal? How approximate? Is it reasonable to emit a table as a simple "table:" + a hexadecimal magic number? As Dirk points out, "reasonable" in this case has the pragmatic definition: "what Roberto thinks is reasonable".
--Tim
- References:
- why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, pulleyzzz_gmail
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Leo Razoumov
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Coda Highland
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Roberto Ierusalimschy
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Tim Hill
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Dirk Laurie
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, Tim Hill
- Re: why tostring for number use LUA_NUMBER_FMT "%.14g", not "%.16g" ?, steve donovan