Bit Basic Operation
为了可以不需要考虑正负问题
Binary Representation
负数定义
-a : (-a) +1
Bit Operation
& vs && Bitwise difference
| Bitwise OR
~ Bitwise NOT
^ Bitwise XOR(异或)
一样是0,不一样是1
<< Left shift 右侧补零
>> Right shift 正数左侧补充零,负数左侧补充1
>>> Right shift左侧补零
all time complexity are O(1)
Bit Getter
x>> k
Bit Setter
Last updated