lua-users home
lua-l archive

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


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