口诀巧记位运算符应用 参考原文 我在原文基础上加了记忆口诀,见括号内容 1. 按位与 & (0死1活) 清零特定位(mask中特定位置0,其他位为1,s = s&mask) 取某数中指定位(mask中特定位置1,其他位为0,s = s&mask) 2. 按位或 | (让一部分人先富起来) 常用来将原操作数某些位置1,其他位不变。(mask中特定位置1,其他位为0 s = s|mask) 3. 位异或^ (策反) 使特定位的值取反(mask中特定位置1,其他位为0,s = s^mask)