5
至少在我自己的想法中,我遇到了一些奇怪的行爲,同時調試一些涉及確定添加操作是否會使雙精度下溢的代碼。這是一個演示我發現的示例程序。在numeric_limits中有一個錯誤,或者我只是困惑?
#include <iostream>
#include <limits>
using std::cout;
using std::endl;
using std::numeric_limits;
int main()
{
double lowest = numeric_limits<double>::lowest();
bool truth = (lowest + 10000) == lowest;
cout << truth << endl;
}
當我執行此代碼時,我得到true作爲結果。這是一個錯誤還是我只是睡覺剝奪?
OP(例如Matthew)絕對應該閱讀http://floating-point-gui.de/ – 2014-09-11 05:25:29
@MatthewPapageorge也看看:[雙精度浮點格式](http://en.wikipedia.org/ wiki/Double-precision_floating-point_format) – Rimas 2014-09-11 05:29:37
感謝您的迅速和明確的迴應,約翰。對此,我真的非常感激。感謝Basile和Rimas閱讀材料。 – 2014-09-11 05:34:42