【发布时间】:2013-04-16 19:34:03
【问题描述】:
假设我的计算机使用 IEEE 754 浮点编码,我想知道以下函数返回 false 的最小数字是多少:
constexpr bool test(const unsigned long long int x)
{
return static_cast<unsigned long long int>(static_cast<double>(x)) == x;
}
【问题讨论】:
-
2**53 + 1,我想。换一种说法 0x20000000000001
-
糟糕,问题是针对 "==" 而不是 "!="
标签: c++ integer double floating-accuracy floating-point-precision