Here is a simple code in C++ which I am compiling using TDM-GCC 5.1 32bit (gcc-5.1.0-tdm-1-core) on a Windows 8.1 64bit Intel core i-7 machine.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a, b;
a = 0.002;
b = 0.004;
cout << std::sqrt(a*a+b*b)<< endl;
return 0;
}
But on running, it gives the following output
nan
However, it works correctly with TDM-GCC 32bit compiler on a 32 bit machine.
Also, when I am changing the datatype to float, it is working properly on both 32bit and 64 bit computers.
What is wrong here?