3
Win32上将double类型转换为unsigned int会截断为2,147,483,648
编译以下代码: double getDouble() { double value = 2147483649.0; return value; } int main() { printf("INT_MAX: %u\n", INT_MAX); printf("UINT_MAX: %u\n", UINT_MAX); printf("Double value: %f\n", getDouble()); printf("Direct cast value: %u\n", (unsigned int) getDouble()); double d = getDouble(); printf("Indirect cast value: %u\n", (unsigned int) d); return 0; } 输出(MSVC x86): INT_MAX: 2147483647 UINT_MAX: …