如何以8位表示的二进制数替换不操作 [英] How Do I Do Alternate Not Operation For Binary Number Represented In 8 Bit
本文介绍了如何以8位表示的二进制数替换不操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:10010110
适用于从右到左的第1,第3,第5,第7位置的操作
eg:10010110
apply not operation to 1st,3rd,5th,7th position from right to left
推荐答案
使用XOR运算符带掩码,其值为1,位为反转位,0为位,保持不变。
10010110 XOR 10101010 = 0011100
Use XOR operator with a mask having value one in the position of bits to invert and zero for bits to leave unchanged.
10010110 XOR 10101010 = 0011100
这篇关于如何以8位表示的二进制数替换不操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文