[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing 32 bits hexa from LUA to C - LuaJIT
- From: Doug Currie <doug.currie@...>
- Date: Sun, 6 Mar 2011 17:41:15 -0500
On Mar 6, 2011, at 4: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 ?
Try using signed integers.
> =-0x80000000
-2147483648
> =bit.bor(-2147483648,0xff0000ff)
-16776961
>
e