简体   繁体   English

在XOR中是独一无二的,真的适合两个以上的输入吗?

[英]Is Exclusive in XOR really appropriate for more than two inputs?

What does Exclusive in XOR really mean for more than two inputs? XOR中的Exclusive对两个以上的输入意味着什么? Doesn't word Exclusive suggest only one input must be true and not odd number of inputs. 不包括单词表示只有一个输入必须为真,而不是奇数个输入。 Note that the inputs are in sequence. 请注意,输入是按顺序的。 This may seem like duplicate question but all similar questions answer for only two inputs and hence causes me confusion. 这似乎是重复的问题,但所有类似的问题只回答了两个输入,因此引起了我的困惑。

Exclusive OR is defined for two operands only, like eg addition. 仅为两个操作数定义异或,例如加法。 Just like an addition, it happens to be associative . 就像添加一样,它恰好是关联的 This means 这意味着

(a xor b) xor c = a xor (b xor c)

for all inputs a , b and c . 对于所有输入abc

For associative operations, it is customary to drop parentheses because they cannot change meaning of an expression: 对于关联操作,通常会删除括号,因为它们不能更改表达式的含义:

(a + b) + c = a + (b + c) = a + b + c
(a xor b) xor c = a xor (b xor c) = a xor b xor c

One can loosely speak of xor-ing together a bunch of values, but the underlying operation always takes two operands. 人们可以松散地谈论将一堆值放在一起,但底层操作总是需要两个操作数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM