C++ FAQ学习笔记 26章 内置原始类型等

来源:互联网 发布:王传君我不喜欢知乎 编辑:程序博客网 时间:2024/05/24 01:32

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;
 }