int _tmain(int argc, _TCHAR* argv[])
{
int a = (WORD)2 - (WORD)10;
__int64 c = (WORD)2 - (WORD)10;
int d = (DWORD)2 - (DWORD)10;
__int64 b = (DWORD)2 - (DWORD)10;
return 0;
}
如上:我写了段简单的代码,但是运行结果却是:
a=-8, b=4294967288, c=-8, d=-8
运行平台: win7 32位, VS2008
百思不得其解上面的结果,有高人知道烦请告知下,不胜感谢!!
...全文
1256打赏收藏
C++中整数转换的奇异问题
#include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { int a = (WORD)2 - (WORD)10; __int64 c = (WORD)2 - (WORD)10; int d = (DWORD)2 - (DWORD)10; __int64 b = (DWORD)2 - (DWORD)10; return 0; } 如上:我写了段简单的代码,但是运行结果却是: a=-8, b=42