I want to get a result from casting double type to usigned long long type in c++. But that code have different result from Windows and Linux. Here's my code.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << (unsigned long long) pow(10, 18) << endl;
return 0;
}
I just used 'pow' function to get 10 to the 18, and cast it to unsigned long long type. In Windows, It has result of 99999999999999999 (10^18-1), but It has result of 1000000000000000000 (10 ^18) in Linux. I used MinGW g++ for C++11 compilation in Windows and use g++ in Linux. What's the reason of this result? Thanks.