lua-users home
lua-l archive

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

On Sun, Mar 6, 2011 at 10:32 PM, Sylvain Fabre <> wrote:
I try to send a 32 bits uint32_t value from LUA to C (ie in fact a 0xRRGGBBAA pattern) and i am facing the following issue :
  • If i do a 0xFF0000FF -> I get the value 0x80000000 with luaL_checkinteger()
  • If i do not set the MSB (ie 0x7F0000FF for example) -> I get the correct value  with luaL_checkinteger()
I guess it has something to do with sign conversion, but i do not know if it is a bug or a normal behavior with luaJIT.

Any hint or idea ?

0xFF0000FF does not fit in a lua_Integer. Use luaL_checknumber and convert to an unsigned int or similar yourself.