lua-users home
lua-l archive

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


On Thu, Mar 12, 2020, at 7:35 PM, Doug Currie wrote:

So string.unpack("I8", "\255\255\255\255\255\255\255\255")
should be an unsigned integer with value 18446744073709551615.

The problem is not in string.unpack, but how the result is printed.

> string.format("%u", string.unpack("I8", "\255\255\255\255\255\255\255\255"))

18446744073709551615


e

I didn't understand that returning a lua_Integer is the intended behavior for all integers.
The presence of the "J" conversion option was especially confusing, it seemed to imply
the presence of unsigned 64 bit integers.

I have two suggestions to clear this up for future users:
- Error on a set sign bit in the "J" and "I8" conversion options
- Add a note to the manual section 6.4.2 about this

Thank you all for your help