Platform: Linux GCC
Question:
unsigned int test_bits_1 = 0x00000001;
printf("test_bits_1 = 0x00000001, test_bits_1 << 32 = %X\n",
test_bits_1 << 32);
printf("0x01 << 32 = %X\n", 0x01 << 32);
輸出結果
test_bits_1 = 0x00000001, test_bits_1 << 32 = 1
0x01 << 32 = 0
請問問題出在哪裡?
我以為結果test_bits_1 << 32 = 0
程式碼(Code):
unsigned int test_bits_1 = 0x00000001;
printf("test_bits_1 = 0x00000001, test_bits_1 << 32 = %X\n",
test_bits_1 << 32);
printf("0x01 << 32 = %X\n", 0x01 << 32);
作者: michael47 (hitman) 2014-08-26 17:11:00
請問樓上的意思是說當type為int(4個bytes)會這樣嗎?請問樓上可以提供造成這樣結果的資料來源嗎?我已經找到答案了,感謝樓上suhorng的提醒