[問題] bit shift << 的問題
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);
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.166.2.127
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1409036665.A.B8D.html
※ 編輯: michael47 (118.166.2.127), 08/26/2014 15:09:46
※ 編輯: michael47 (118.166.2.127), 08/26/2014 15:11:28
推
08/26 16:25, , 1F
08/26 16:25, 1F
→
08/26 17:11, , 2F
08/26 17:11, 2F
→
08/26 17:12, , 3F
08/26 17:12, 3F
→
08/26 17:37, , 4F
08/26 17:37, 4F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章