lua-users home
lua-l archive

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


   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.

/Stefan

> -----Original Message-----
> From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-
> bounces@bazar2.conectiva.com.br] 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
> >>> about?
> >>
> >>> print(0x10000000)
> >>> 268435456
> >>>
> >>> print(0x10000000 + 0x00000001)
> >>> 268435456
> >>>
> >>> print(0x10000000 + 0x00000002)
> >>> 268435456
> >>
> >> 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?
> >>
> >> http://docs.sun.com/source/806-3568/ncg_goldberg.html
> >>
> > This is on Win32 (Lua is part of our game engine).  We did not
modify
> > 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.
> >
> > Brian
> >
> 
> 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
> right?
> 
> Brian
> 
>