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