现在的位置: 首页 > 综合 > 正文

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

2017年12月18日 ⁄ 综合 ⁄ 共 259字 ⁄ 字号 评论关闭

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

抱歉!评论已关闭.