lua-users home
lua-l archive

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



Me, yesterday, 14:21

Also "lua_tounsigned()" would be handy.

:)  imho, the whole integer support should be revised.


Jerome Vuarand kirjoitti 15.11.2006 kello 0.13:

David Given wrote:
Therefore, casting (double)0xFFFFFFFF to an unsigned int is
valid, but it's
*not* valid to cast it to an int. Casting it to an unsigned
int and *then* to an int is valid, and will result in 0xFFFFFFF.

Anything else invoces undefined behaviour, and results in
daemons flying out of your nose.

lua_Integer is a typedef for ptrdiff_t, which must be signed. So for
safe extraction of unsigned integers in stock Lua there may be a need
for a lua_UnsignedInteger typedef, and a lua_tounsignedinteger function.
Maybe lua_Unsigned and lua_tounsigned would be clear enough.