I am puzzled on this code snippet:
#include <climits>
#include <iostream>
int main(void) {
using namespace std;
cout << "long max " << LONG_MAX << endl;
long x = 2 * 1024 * 1024 * 1024;
cout << "2 * 1024 * 1024 * 1024 = " << x << endl;
return 0;
}
I was expecting 2147483648 as it should be, instead I am getting. Using unsigned doesn't seem to help. what gives?
long max 9223372036854775807
2 * 1024 * 1024 * 1024 = -2147483648