In C++, I use the following code to work out the order of magnitude of the error due to the limited precision of float and double:
float n=1;
float dec = 1;
while(n!=(n-dec)) {
dec = dec/10;
}
cout << dec << endl;
(in the double case all I do is exchange float with double in line 1 and 2)
Now when I compile and run this using g++ on a Unix system, the results are
Float 10^-8
Double 10^-17
However, when I compile and run it using MinGW on Windows 7, the results are
Float 10^-20
Double 10^-20
What is the reason for this?