[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work1) now available
- From: Sean Conner <sean@...>
- Date: Tue, 9 Jul 2013 17:42:52 -0400
It was thus said that the Great Sean Conner once stated:
> It was thus said that the Great Roberto Ierusalimschy once stated:
> > > Just so I understand, what was the rationale for choosing 64 over 32 as the integer size?
> >
> > We have just discussed this subject today, a few hours ago. Check
> > the list. (The main rationale for having integers is to allow 64-bit
> > integers; you will not have 64-bit integers with a 32-bit integer size.)
>
> As a thought---I know it's not C89, but what about changing the default
> Lua numeric type to "long double" for those that need 64-bit integers? I
> checked my 32-bit system and it reports back "12" for sizeof(long double),
> and in the 64-bit system, it reports back '16'. To me, that seems like both
> would be large enough to support true 64-bit integers.
>
> -spc (That way, not much has to change internally ... )
As "proof-of-concept", I took the source to Lua 5.2.2 and made the
following changes:
[spc]saltmine:~/apps/lua-5.2.2/src>diff luaconf.h /tmp/lua-5.2.2/src/luaconf.h
387c387
< #define LUA_NUMBER long double
---
> #define LUA_NUMBER double
393c393
< #define LUAI_UACNUMBER long double
---
> #define LUAI_UACNUMBER double
402,403c402,403
< #define LUA_NUMBER_SCAN "%Lf"
< #define LUA_NUMBER_FMT "%.28Lg"
---
> #define LUA_NUMBER_SCAN "%lf"
> #define LUA_NUMBER_FMT "%.14g"
[spc]saltmine:~/apps/lua-5.2.2/src>diff lmathlib.c /tmp/lua-5.2.2/src/lmathlib.c
100c100
< lua_Number fp = l_mathop(modfl)(luaL_checknumber(L, 1), &ip);
---
> lua_Number fp = l_mathop(modf)(luaL_checknumber(L, 1), &ip);
I then did a "make ansi". The results:
[spc]saltmine:~/apps/lua-5.2.2>./src/lua -E
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> print(2^63)
9223372036854775808
> print(2^63+1)
9223372036854775809
> print(2^64)
18446744073709551616
> print(2^64+1)
18446744073709551616
> print(2^64-1)
18446744073709551615
-spc (Seems like a promising approach ... )