我刚刚注意到在我的系统上std::nextafter(0, 1)
似乎产生了一个大于0且小于std::numeric_limits::min()
的值。
这怎么可能?我以为min()
返回大于0的最小可能数字。
#include <iostream>
int main(int argc, char *argv[])
{
double next = std::nextafter(0.0, 1.0);
double min = std::numeric_limits<double>::min();
std::cout << "next: " << next << "\nmin: " << min << "\nnext<min: " << (next < min) << "\nnext>0: " << (next > 0.0) << std::endl;
}
输出:
next: 4.94066e-324
min: 2.22507e-308
next<min: 1
next>0: 1
我的编译器是MinGW 5.3.0 32位版本。