I cannot reproduce numeric_limits<double>::epsilon()
I have tried the following code:
#include <iostream>
#include <limits>
using namespace std;
int main()
{
double x = 1;
double s = 0;
for(double y = x; y == x; y = x+(s+=x*1e-20)) {}
cout << "my calculation: " << s << endl;
cout << "epsilon(): " << numeric_limits<double>::epsilon() << endl;
return 0;
}
Output is:
my calculation: 1.1108e-016
epsilon(): 2.22045e-016
Only half! Why?