Darren Duncan writes: > 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?
Naively, yes. And mathematics othen revels in the naive position (any other would not be consistent): xor(1, 0, 0, 1, 1, 0) 1 xor 0 xor 0 xor 1 xor 1 xor 0 1 xor (0 xor (0 xor (1 xor (1 xor 0)))) 1 # parity 1, odd number of arguments true > 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? I don't think that's what xor is testing. I can't quite think of why you'd need that (but I can't quite think of why you'd need xor either...). Luke