對於我確定性的物理引擎,我需要確認C#中的雙打計算在多個平臺上足夠一致。有誰知道下列功能在結果上有多少差異?在我的計算機作爲Windows 32位應用程序,這些都是結果(注:僞代碼):跨多個平臺的雙數學一致嗎?
double x = 123.123;
x * 2 = 246.246
Math.Pow (x, 2) = 15159.273129
Math.Sqrt (x) = 11.0960803890383
Math.Sin (x) = -0.56537391969734
我仍然不知道,如果同樣的結果會變成了在其他平臺或其他語言(我使用C#)。如果需要更多信息,我會盡快提供。如果有任何人有知識或有時間幫助測試其他平臺上的計算,請幫助我克服這種不確定性。
這不是一個完全重複的內容,但是您可以從[跨平臺浮點合併]中的問題和答案中獲得一些見解(http://stackoverflow.com/questions/20963419/cross-platform-floating-point-consistancy )。 – Simon 2015-02-10 02:57:14
http://stackoverflow.com/questions/28389634/is-double-math-deterministic-enough-for-physics-simulations http://stackoverflow.com/questions/7365790/how-can-floating-point-calculations- be-made-deterministic http://stackoverflow.com/questions/20963419/cross-platform-floating-point-consistancy – 2015-02-10 03:36:13
哦,謝謝。我會檢查這些鏈接。 – JPtheK9 2015-02-10 05:12:02