实用公式:

a + b = a | b + a & b

异或

性质:两个数异或相当于各位进行无进制的二进制加法

重要公式:

1^1=0 x^x=0
a^b=x a^x=b

__builtin_popcount函数(统计二进制中‘1’的个数)

  1. __builtin_popcount(unsigned int n) //返回int类型
  2. __builtin_popcountll(unsigned int n) //返回long long类型