Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7091687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:13:03+00:00 2026-05-28T08:13:03+00:00

I’m writing a D3D application which uses DXUT for initializing device and handling all

  • 0

I’m writing a D3D application which uses DXUT for initializing device and handling all the events. Though, I found a weird behavior: once I create a device all the double precision calculation in the application get broken. After some debugging I simplified code to this:

bool CALLBACK AlwaysTrue(D3DCAPS9*, D3DFORMAT, D3DFORMAT, bool, void*) {
  return true;
}

INT WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, INT) {
  // Commenting line below solves the problem.
  DXUTSetCallbackD3D9DeviceAcceptable(AlwaysTrue);
  DXUTInit(true, true);
  DXUTCreateWindow(L"Issue with doubles");

  __int64 val = 1326778320508821LL;
  double a1 = 0.000001 * val;  // 1326778320.5088210
  DXUTCreateDevice(true, 640, 480);
  double a2 = 0.000001 * val;  // 1326778368.0000000

  DXUTMainLoop();
  return DXUTGetExitCode();
}

Well, I’m pretty sure here we have float/double issue but I fail to understand how it get triggered and how to workaround it. I tried to debug at asm level and found out that code is 100% same for a1 and a2 which makes me think it’s a FPU state issue.

For some reason commenting out first line in the main method fixes problem.

Does anybody know what is happening here and point may be some docs to learn more about this issue? My application definitely needs double precision calculations.

PS. VS2008 SP1, SSE/SSE2 turned off, floating point model: precise.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:13:03+00:00Added an answer on May 28, 2026 at 8:13 am

    When D3D9 device is created with the default flags, it sets the FPU precision to 24 bits.
    In order to prevent this, you have to set D3DCREATE_FPU_PRESERVE flag when creating the device.

    Note that DXSDK docs discourage you from doing this, in case you change FPU state to enable exceptions:

    Portions of Direct3D assume floating-point unit exceptions are masked;
    unmasking these exceptions may result in undefined behavior.
    

    With default FPU state you should be fine though.

    In order to do this with DXUT, you’ll have to use ModifyDeviceSettings callback, set via DXUTSetCallbackDeviceChanging, i.e.:

    bool CALLBACK ModifyDeviceSettings( DXUTDeviceSettings* pDeviceSettings, void* pUserContext )
    {
        assert( DXUT_D3D9_DEVICE == pDeviceSettings->ver );
    
        pDeviceSettings->d3d9.BehaviorFlags |= D3DCREATE_FPU_PRESERVE;
    }
    
    DXUTSetCallbackDeviceChanging(ModifyDeviceSettings);
    

    As to why setting device acceptable callback fixes the issue: I think that in this case by setting a D3D9 callback you force DXUT to use D3D9; if you don’t force it to use D3D9, it tries to create a D3D10 device and succeeds; creating D3D10 device does not change FPU state, so the bug goes away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.