我的代码:
int main()
{
long long a = pow(2,63) - 1;
long long b = pow(2,63);
double c = pow(2,63) - 1;
double d = pow(2,63);
printf("%lld %lld \n%f %f \n%lld %lld\n", a, b, c, d, (long long)c, (long long)d);
return 0;
}
并且执行结果是(在win7 x64中使用gcc的代码块):
9223372036854775807 9223372036854775807
9223372036854775800.000000 9223372036854775800.000000
-9223372036854775808 -9223372036854775808
问题:
为什么a == b
?
我知道这是c == d
因为double
.
但是为什么(long long)c
又(long long)d
不是9223372036854775800
呢?
为什么(long long)c != a
和(long long)d != b
?