位运算
实用公式:
a + b = a | b + a & b
异或
性质:两个数异或相当于各位进行无进制的二进制加法
重要公式:
1^1=0
a^b=x
__builtin_popcount函数(统计二进制中‘1’的个数)
- __builtin_popcount(unsigned int n) //返回int类型
- __builtin_popcountll(unsigned int n) //返回long long类型
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.


