Bit Operation

In this doc we will talk about bit operations basics and some common bit manipulation tricks that can help solve problems in programming & interviews.

位运算的主要思想是五种运算:与(&),或(|),异或(^),左移(<<),右移(>>)。
位运算的常用技巧如下:

n &(n-1)能够消灭n中最右侧的一个1。
右移:除以2, 左移:乘以2。
异或性质:交换律,0^a=a, a^a=0;