<分区>
Possible Duplicate:
How do you set, clear and toggle a single bit in C?
我正在为即将到来的期末考试学习,我想验证学习指南中的一些问题。
一些上下文:
Set()
函数将字节中的一位设置为 1Unset()
函数将字节中的某个位设置为 0Flip()
函数将位“翻转”到与原来相反的位置
所以我们类的某个 child 主动回答了学习指南的问题,但我已经发现了一些错误,这些答案听起来很可疑。他是这样说的:
Which operation is used for the Set? the or operator |
Which operation is used for the Unset? Xor operator ^ Done twice
Which operation is used for the Flip? Xor operator ^
在我上面描述的函数中,这些是正确的按位运算符吗?