[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LUA_NUMBER -> Integer conversion bug
- From: Sebastian Rohde <rohde@...>
- Date: Fri, 10 Mar 2006 18:31:34 +0100
Hi everybody,
In lua 5.1 I found out that on my machine this code does not work out of the
box (luaconf.h).
(VC8, Athlon64)
When I comment this out everything works great with the fallback cast.
int k;
double d = 1.d;
After calling "lua_number2int(k, d);" k was still 0. I didn't investigate
further but this let arrayindex(..) work incorrect and therefore tables were
handled incorrectly (e.g. lua_next(..))
#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__)
&& \
(defined(__i386) || defined (_M_IX86) || defined(__i386__))
union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) \
{ volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) =
u.l_l; }
If you have anymore questions feel free to ask - I will be in the office at
monday again.
Sebastian Rohde
Programmer
Blue Byte GmbH
www.bluebyte.de | www.ubisoft.de | www.ubi.com
Phone: +49 (0) 211 / 33800-523
Email: rohde@bluebyte.de