一些初始bits
- All zeros except for a 1 at position p
1 << p
- All zeros followed by P ones
(1 << p) - 1
- A sequence of ones followed by P zeros
~((1 << p) - 1)
运算顺序
算术运算 > 位移运算 > 位运算 > 逻辑运算
Questions:下列式子相等吗?
1. 1 << 10 - 1
与1 << (10 - 1)
2. 10 - 1 >> 1
与(10 - 1) >> 1
Answers:
1. 算术运算 > 位移运算 完全相等
2. 不等