C++ FAQ學習筆記 26章 內置原始類型等

sizeof(char)永遠爲1

sizeof的單位爲byte

c++ byte一般爲8位,但是也有c++的實現中byte多於8位的

c++一個字節多少位可以在如下實現中找到 include the header <climits>, then the actual number of bits per byte will be given by the CHAR_BIT macro.

如何判定一個數是2的倍數

 inline bool isPowerOf2(int i)
 {
   return i > 0 && (i & (i - 1)) == 0;
 }

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