|
-
July 6th, 2012, 08:20 AM
#6
Re: Double arithmetic seems bugged
After a whole day trying to figure this out I found that the cause is DirectX (I didn't mention that I am using DirectX, because it didn't seem relevant at first) and I think this is worth mentioning here.
DirectX switches on some secret CPU mode that treats all double precision arithmetic as single precision. Hence, my doubles start to behave like floats and this makes the use of double a waste of memory (and possibly performance) since you don't get the accuracy of a double. Turning this "feature" in DirectX off is possible, but at a performance cost.
This article explains it fine:
http://chrisvall.com/coding/directx-...lizing-directx
I have added the most basic DirectX initialization to my test program (which couldn't reproduce this problem) and now it behaves in the same (incorrect) manner. So I think I will be looking for a solution to do my time calculations with floats.
EDIT: It stays a bit of a mystery though, why the Visual Studio Watch window CAN do the calculation properly (with double precision)...
Last edited by klapstoelpiloot; July 6th, 2012 at 08:22 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|