lua-users home
lua-l archive

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


It's not a bug, it's natural. lua_Number as "double" is 64 bits long, part of which is exponent. Redefine lua_Number as "long double" if you want it to hold 64-bits integers. AFAIR, you'll also have to redifine another constant together with lua_Number.







----- Original Message ----- From: liam mail
To: Lua list
Sent: Sunday, December 13, 2009 6:11 PM
Subject: Bug in Lua when using signed long


On macosx x64 where long is eight bytes and lua_Integer is defined as ptrdiff_t which is also eight bytes long, the following fails:
       signed long input((std::numeric_limits<signed long >::max)());
       lua_pushinteger(L, input );
       signed long result = ( lua_tointeger( L, -1) );
       CPPUNIT_ASSERT_EQUAL(input, result);

- Expected: 9223372036854775807
- Actual : -9223372036854775808