lua-users home
lua-l archive

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

On Sun, Jan 9, 2022 at 1:12 PM Halalaluyafail3 <> wrote:
> As for the original question:
> The border is not defined as an integer but a natural number. Therefore
> border + 1 will never overflow to a negative number and since maxinteger
> + 1 is not a valid integer any more it cannot be found in the table and
> therefore is nil. So maxinteger is always a border if maxinteger has a
> non nil value. (This is at least how I would read it).
I read it as being a Lua _expression_, so I assumed wrap-around behavior.
If it is interpreted as being an operation on a natural number, the
same problem will arise if one larger than the maximum integer is
representable as a float.
Would a float which represents a positive integer be considered a
valid integer or a natural number?

This actually is an interesting edge case:
The number MAX_INT + 1 is, in fact, exactly representable by binary floating point because MAX_INT is 2^<Machine bit width> - 1 (assuming 2's complement).
MAX_INT + 2, however, is unrepresentable.