[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_Integer in Lua 5.3
- From: Lourival Vieira Neto <lourival.neto@...>
- Date: Thu, 5 Dec 2013 14:57:09 -0200
On Wed, Dec 4, 2013 at 6:27 PM, Alexander Nasonov <alnsn@yandex.ru> wrote:
> Philipp Janda wrote:
>> Makes sense. "long long" has a much higher chance of being 64 bits on 32
>> bit machines, and having 64 bit integers becomes important in Lua 5.3.
>
> The text below is from pre-C11 standard but I'm pretty sure it's no
> different from C99 (too lazy to unpack a box with my hardcopy of C99,
> I recently moved house).
>
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1539.pdf
>
> 5.2.4.2.1 Sizes of integer types <limits.h>
>
> 1 The values given below shall be replaced by constant expressions suitable
> for use in #if preprocessing directives. Moreover, except for CHAR_BIT
> and MB_LEN_MAX , the following shall be replaced by expressions that
> have the same type as would an expression that is an object of the
> corresponding type converted according to the integer promotions. Their
> implementation-defined values shall be equal or greater in magnitude
> (absolute value) to those shown, with the same sign.
>
> ...
>
> -- minimum value for an object of type long long int
> LLONG_MIN -9223372036854775807 // - (2^63 - 1)
>
> -- maximum value for an object of type long long int
> LLONG_MAX +9223372036854775807 // 2^63 - 1
>
> -- maximum value for an object of type unsigned long long int
> ULLONG_MAX 18446744073709551615 // 2^64 - 1
It is my point. The Lua 5.3 manual states:
"Standard Lua uses *64-bit integers* and double-precision floats, but
it is easy to compile Lua so that it uses 32-bit integers and
single-precision floats. [1]"
And the implementation uses _at least_ 64-bit integers. As both long
long and int64_t are C99, why do not use int64_t? Please note, I'm not
suggesting to use int64_t. I'm just interested to know the reason why
it was not chosen.
Anyway, I think that the manual could be clearer in this point. Also,
lua_Integer definition should be fixed in the section 4.8 of the
manual, as it is defined as long long by default, not ptrdiff_t.
[1] http://www.lua.org/work/doc/manual.html#2.1
Regards,
--
Lourival Vieira Neto