Can floating-point precision be thread-dependent?

半城伤御伤魂 提交于 2019-12-01 17:14:46
Jon Skeet

Yes, I believe the result can be thread-dependent.

My guess is you're using DirectX at some point in your code - and that sets the precision for the FPU, and I believe it sets it on a per-thread basis.

To fix this, use the D3DCREATE_FPU_PRESERVE flag when you call CreateDevice. Note that this will potentially have a performance impact. The managed equivalent is CreateFlags.FpuPreserve.

(See this related question. I haven't suggested that this one be closed as a duplicate, as they at least look a bit different on the surface. Having both should help the answer to be discoverable.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!