1、让某一位变为0
使用 AND逻辑运算,运算数出了指定位为0,其余位为1,
If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
2、让某一位变为1
使用或运算,让指定位变为1,其余为0
If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
博客介绍了通过逻辑运算改变二进制指定位数值的方法。一是使用 AND 逻辑运算让某一位变为 0,运算数除指定位为 0 其余位为 1;二是使用或运算让某一位变为 1,运算数指定位为 1 其余为 0。
6万+

被折叠的 条评论
为什么被折叠?



