我正在写一个程序在C++中,我想找到我的电脑的epsilon。 我想要的结果是双精度(这是2.2204460492503131E-16),但输出是1.0842E-019,这是长双精度的ε。返回长双而不是双重
我的计划是这样的:
#include <iostream>
double e = 1.0;
double x;
int main()
{
for (int i = 0; e + 1.0!=1.0 ; i++)
{
std::cout<<e<<'\n';
x = e;
e/=2.0;
}
std::cout << "The epsilon of this Computer is "<< x <<'\n';
return 0;
}