Path: news.mathworks.com!not-for-mail
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$1@fred.mathworks.com>
References: <gjafh2$6kq$1@fred.mathworks.com> <gjag5n$fl8$1@fred.mathworks.com> <f791474c-8fa9-4300-a86e-7163970ab1e4@z6g2000pre.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1230568818 4706 172.30.248.35 (29 Dec 2008 16:40:18 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 29 Dec 2008 16:40:18 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:509099

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <f791474c-8fa9-4300-a86e-7163970ab1e4@z6g2000pre.googlegroups.com>...
> 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