[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug in Lua when using signed long
- From: Mike Pall <mikelu-0912@...>
- Date: Sun, 13 Dec 2009 20:14:00 +0100
Mark Hamburg wrote:
> > But it would make sense to use an out-of-the-box configuration
> > where lua_Integer is a subset of lua_Number. One could just use
> > LUAI_INT32.
> >
> > Alas, it's a bit too late to fix that now. Changing lua_Integer
> > would break the Lua 5.1 ABI.
>
> My primary use case for integers exceeding the range of ints are
> file offsets. These will pretty much always fit in the precision
> afforded by double but often not in the precision afforded by
> int.
But 64 bit file offsets are not specific to 64 bit platforms. In
other words: using lua_Integer means your code would certainly
break on a 32 bit platform.
That's why e.g. the LJ2 code for fp:seek() (in lib_io.c) uses the
equivalent of lua_tonumber() and lua_pushnumber() for that purpose.
--Mike