Different math rounding behaviour between Linux, Mac OS X and Windows

前端 未结 4 1265
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 07:25

HI,

I developed some mixed C/C++ code, with some intensive numerical calculations. When compiled in Linux and Mac OS X I get very similar results after the simulatio

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-19 08:13

    In addition to the runtime rounding settings that people mentioned, you can control the Visual Studio compiler settings in Properties > C++ > Code Generation > Floating Point Model. I've seen cases where setting this to "Fast" may cause some bad numerical behavior (e.g. iterative methods fail to converge).

    The settings are explained here: http://msdn.microsoft.com/en-us/library/e7s85ffb%28VS.80%29.aspx

提交回复
热议问题