[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What would you remove from Lua - a case of regression?
- From: Philippe Verdy <verdyp@...>
- Date: Mon, 26 Nov 2018 22:50:36 +0100
The same is true for Lua 5.3 when it also adds integers with unspecified limits that are just by default bound to what the C compiler gives in it's int datatype but also allows configuring that type.
Lua numeric types have unpredictable limits
That is not true. Lua is designed to allow its number type to be configurable but in its default configuration it just uses what C gives as a double.
Nothing indicates it can store any 64 bit integer and in fact it can almost never store them in a single number, unless Lua is specifically compiled using long double in C and they are represented as 80 bit with a 64 bit mantissa part...
No there's no standard way to know the limits of numbers in lua. You need to test them by trying some operations in test loops during initialization of your code, and then use these dynamic results as if they were constants. But a Lua interpreter or compiler will never know that they are constants after the initialisation when bref to be variables during the initialization where their final value is still not known.
On Mon, 26 Nov 2018 at 21:21, Philippe Verdy <email@example.com> wrote:
> Unfortunately we still cannot use any strict integer type in Lua without the cost of IEEE doubles, and Lua is already inconsistent with some number operators like shifts and binary ops which truncate operands to ints but return the result by reconverting it to doubles, looking their initial restriction of range and precision.
Hi, Lua 5.3 has 64-bit integer types - I was not sure whether you are
thinking of an earlier version of Lua above.