On Tuesday 12 April 2005 20:45, Darren Duncan wrote:
> At 8:27 PM -0400 4/12/05, John Macdonald wrote:
> >The mathematical definition of xor for two arguments is "true if
> >exactly one argument is true, false otherwise".
> 
> Yes.
> 
> >When that gets
> >generalized to multiple arguments it means "true if an odd number
> >of the arguments are true, false otherwise".
> 
> Is this the official mathematics position?

It's simply chaining a series of 2-arg xor's together.  As it happens, the
result of such chaining comes out as "odd number true" and has the nice
properties of being commutative [a xor b === b xor a] and associative
[((a xor b) xor c) === (a xor (b xor c))].

> If not, I would generalize it like this: true If >= 1 arg is true 
> and >= 1 arg is false, otherwise false.
> 
> Is that better or worse?

The "mathematical" definition can generalize down to one or zero
elements as well as up to n.

> >   So, you cannot short
> >circuit the evaluation because any value, if it happens to be true,
> >changes the result of the expression.
> 
> If my assertion is used, then all you can short circuit once you find 
> a true value and a false value.

Well, it's a function that can be short circuited, but it's not xor and would
have different uses.

Reply via email to