`
gushuizerotoone
  • 浏览: 172705 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

位运算 bit

 
阅读更多
1. a<<b  =>  a*2^b ; a>>b => a/2^b
2. 并A|B; 交A&B; 减集 A&~B; 负集ALL_BITS^A

注意第bit位is indexed from 0 not 1;
3. set 第bit位为1: A=A|(1<<bit); clear 第bit位为0: A=A&~(1<<bit)
4. test 第bit位是不是1: (A&1<<bit)!=0
5. 判断B是不是A的子集 (A&B) == B
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics