位运算符 &^ 能拆分其他位运算符表示吗?因为这个位运算符其他语言C还有rust都没有。

wandercn · 2021-09-23 13:44:10 · 1364 次点击
更多评论
czyt
云在青天水在瓶

这个操作叫做 bit clear ,搜了下,希望对你有所帮助。

1、Setting a bit. Use the bitwise OR operator ( | ) to set a bit. number |= 1 << x; That will set a bit x .

2、Clearing a bit. Use the bitwise AND operator ( & ) to clear a bit. number &= ~(1 << x); That will clear bit x . ...

3、Toggling a bit. The XOR operator ( ^ ) can be used to toggle a bit. number ^= 1 << x;

#1
wandercn
https://hotbuild.rustpub.com

@dagongrenzzZ 谢谢,可以了

#3