lua-users home
lua-l archive

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

Stefan Boberg wrote:
   Direct3D is probably changing the FPU mode to single-precision under
your feet. There's an initialization flag you can pass to D3D on
creation which will avoid this.


-----Original Message-----
From: [mailto:lua-] On Behalf Of Brian Weed
Sent: 01 September 2006 18:17
To: Lua list
Subject: Re: print(268435456 + 1)

Brian Weed wrote:
Aaron Brown wrote:
Brian Weed wrote:

Is there something about adding numbers that I should know

print(0x10000000 + 0x00000001)

print(0x10000000 + 0x00000002)
I get 268435456, 268435457, and 268435458.  My first guess
is that you're using (single-precision) floats instead of
doubles.  What platform are you on?  Did you change
LUA_NUMBER when compiling?

This is on Win32 (Lua is part of our game engine).  We did not
LUA_NUMBER.  It's still double.
Lua is compiled as a static lib via Visual C++ 6.0.  The app is
compiled via Visual Studio 2005.


Ok, this is really weird...

The following C code has the same problem (while watching "d" in the
debugger in Visual C++ 6.0):

double d = 0x10000000;

d = d + 0x00000002;

doubles are supposed to be able to completely represent  a 32bit int

I had heard you guys talk about this D3D9 issue before, but for some reason, I thought it would not affect me.

So, I added D3DCREATE_FPU_PRESERVE, and that solved the problem.

Thanks, everyone.