std::pow produce different result in 32 bit and 64 bit application

后端 未结 4 1130
旧巷少年郎
旧巷少年郎 2020-12-11 18:20

I have found the mismatch in the result of some complex calculations. When i thoroughly observed the intermediate results, its the std::pow function which creates that misma

4条回答
  •  [愿得一人]
    2020-12-11 18:47

    From the wikipedia page on long double

    On the x86 architecture, most C compilers implement long double as the 80-bit extended precision type supported by x86 hardware [...]. An exception is Microsoft Visual C++ for x86, which makes long double a synonym for double.

    So when you are compiling on 32 bit long double = double, but on x64 long double is actually an 80 bit floating point, so the results are different.

提交回复
热议问题