[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Bug in string.unpack
- From: cherue <cherue.lual@...>
- Date: Thu, 12 Mar 2020 20:55:00 +0100
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"))
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