[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] file_slurp - read/write entire files from/to a string (module design discussion)
- From: David Manura <dm.lua@...>
- Date: Sat, 5 Nov 2011 18:28:22 -0400
On Thu, Nov 3, 2011 at 10:43 PM, HyperHacker <firstname.lastname@example.org> wrote:
> On Thu, Nov 3, 2011 at 20:29, David Manura <email@example.com> wrote:
>> For example, _VERSION = 0.001001 is a
>> number (not string) of the form x.yyyzzz, which is a style that may be
>> debatable but allows trivial numeric comparison .
> Getting into 6 decimal places, I start to get nervous about loss of precision...
It works even when Lua is compiled with IEEE floats:
for i=1000,10000000 do
local version = i / 1E6
assert(string.format("%1.6f", version) == string.format("%d.%06d",
(i-(i%1E6))/1E6, i % 1E6))
end; print 'OK'
but not if Lua is compiled with integers, so maybe floats are bad here.
"Version numbers should be boring"