[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_number2int
- From: Asko Kauppi <askok@...>
- Date: Wed, 15 Nov 2006 01:20:33 +0200
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
Maybe lua_Unsigned and lua_tounsigned would be clear enough.