lua-users home
lua-l archive

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

> 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

The manual for the new version (5.4) already has a note about this:

  All integral options check overflows; string.pack checks whether the
  given value fits in the given size; string.unpack checks whether the
  read value fits in a Lua integer.  For the unsigned options, Lua
  integers are treated as unsigned values too.

As a bit of self promotion, the fourth edition of "Programming in Lua"
has a nice section (Section 13.2) about the manipulation of unsigned
integers in Lua.

-- Roberto