cssap_2_homework_bit_operation
来源:互联网 发布:linux上安装maven 编辑:程序博客网 时间:2024/06/06 08:45
function bitParity(int x) { x ^= x >> 16; x ^= x >> 8; x ^= x >> 4; x &= 0xf; return (0x6996 >> x) & 1;}
Finding odd number of bits in an integer
0x6996
serves as a lookup table - for each number between 0 and 15 you choose one of its bits
nt
leftmost_one
(unsigned x){
x |= (x >>
1
);
x |= (x >>
2
);
x |= (x >>
4
);
x |= (x >>
8
);
x |= (x >>
16
);
return
x^(x>>
1
);
nt
leftmost_one
(unsigned x){
x |= (x >>
1
);
x |= (x >>
2
);
x |= (x >>
4
);
x |= (x >>
8
);
x |= (x >>
16
);
return
x^(x>>
1
);
int leftmost_one(unsigned x){x |= (x >> 1);
x |= (x >> 2);
x |= (x >> 4);
x |= (x >> 8);
x |= (x >> 16);
return x^(x>>1);
}
Generate mask indicating leftmost 1 in x
int lower_one_mask(int n){
return (2<<(n-1)) - 1;
}
or
{
return ~(~0 << n);
}
Mask with least signficant n bits set to 1
0 0
- cssap_2_homework_bit_operation
- addEventListener事件
- Unity-WWW发送Http请求
- 正则表达式
- linux history
- C#项目发布到IIS后CSS及Jquery出现问题的几种情况
- cssap_2_homework_bit_operation
- 软件测试学习笔记
- 我的第一篇博客
- 【高质量Objective-C-1】目录结构-Effective Objective-C 2.0
- CSS应用:过渡
- 空悬指针和野指针
- 如何分析堆的dump
- Kafka主要参数详解
- BeanUtils 转换器将Long ,Integer等数字类型的默认值设置为null