tags:

views:

184

answers:

2

I recently added some DirectX code to my program, and now my double data type variables only have the range/resolution of a float (.. or atleast less range/resolution than they used to). If I remove the direct3D initialization - "Direct3DCreate9(D3D_SDK_VERSION)" - the problem goes away. Any insight? Thanks.

+4  A: 

Direct3D will modify the FPU state to force single precision mode.

If you want to preserve double-precision mode, use D3DCREATE_FPU_PRESERVE when you create the D3D device. That will have an effect on the performance of D3D though:

http://msdn.microsoft.com/en-us/library/bb172527(VS.85).aspx

MSN
+1  A: 

As explained in this blog entry: Direct3D and the FPU, you can tell Direct3D not to change the FPU mode to single precision:

Luckily, you can avoid all of this by simply telling Direct3D not to mess with the FPU at all. When creating the device you should use the CreateFlags.FpuPreserve flag to keep the CLR's double precision, and have your code functioning as you expect it.

Greg Hewgill