位运算

来源:互联网 发布:淘宝销售属性怎么设置 编辑:程序博客网 时间:2024/05/01 00:17

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.

原创粉丝点击