From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: bitxor for n elements
Date: Mon, 29 Dec 2008 16:40:18 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <gjauhi$4j2$>
References: <gjafh2$6kq$> <gjag5n$fl8$> <>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1230568818 4706 (29 Dec 2008 16:40:18 GMT)
NNTP-Posting-Date: Mon, 29 Dec 2008 16:40:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:509099

ImageAnalyst <> wrote in message <>...
> On the odd chance that you're looking to xor three numbers....
> Since xor is normally "this or that but not both" then you might
> define one for three numbers as
> "number1 or number 2 or number 2 but not any two nor all three"
> In that case, you can just sum the numbers (if they're binary 0/1) and
> check to see if the sum is exactly 1.  If the total of all three
> numbers is 1 then it's true, else it's false.
> Regards,
> ImageAnalyst

  That's not quite right, ImageAnalyst.  For three booleans it should be either any one of them or else all three.  If summing any number of 0/1 booleans, the sum should be an odd number for a true answer to 'xor'.

  However, Suzi mentioned 'bitxor' and such summation wouldn't work in a bitwise manner.  As David states looping is undoubtedly the best way.

Roger Stafford