uint64_t移位

uint64_t a = 0x1234567887654321;
uint64_t b = 1;
int shift;

for(shift = 0; shift < 64; shift++)
    b = 1 << shift;

 

shift = 31

shift = 32

shift = 33

 

注意:位移操作默認1是32bit的,如要使用64bit需要強制聲明1ULL。
      

for(shift = 0; shift < 64; shift++)
    b = 1ULL << shift;

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章