Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在不使用的情况下实现按位异或^?
^
1)与其他按位运算?
2)算术运算?
a xor b == (a and (not b)) or ((not a) and b)
我不知道您为什么要这样做,但是: (a|b)&~(a&b)或者(a&~b)|(b&~a) 算术版本似乎太复杂了,如果没有充分的理由就无法尝试。
(a|b)&~(a&b)
(a&~b)|(b&~a)