lua-users home
lua-l archive

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


On Thu, Nov 3, 2011 at 10:43 PM, HyperHacker <hyperhacker@gmail.com> wrote:
> On Thu, Nov 3, 2011 at 20:29, David Manura <dm.lua@math2.org> 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 [2].
> 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.

[1] http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/
     "Version numbers should be boring"