位运算

博客介绍了通过逻辑运算改变二进制指定位数值的方法。一是使用 AND 逻辑运算让某一位变为 0,运算数除指定位为 0 其余位为 1;二是使用或运算让某一位变为 1,运算数指定位为 1 其余为 0。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值