Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XOR

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
Hi all,

Is XOR logically equivalent to any combination of other operators?

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
if you mean the exclusive or statement, you can try something like this, although i'm not sure of its range of cross-browser support...

Code:
var x = true;
var y = false;

alert(x ^ y);

var x = false;
var y = true;

alert(x ^ y);

var x = true;
var y = true;

alert(x ^ y);

var x = false;
var y = false;

alert(x ^ y);

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
I know how to use it, but I want to know if it has a logical equivalent among a combination of other operators.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Not to state the obvious, but I guess it's logically equivalent to the ^ operator! :)

Since XOR means that one is true or the other is true but not both are true:

(x||y) && !(x&&y)

Is that what you're after?

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Yeah, stop in OPSP and say hi sometime [smile]

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
images
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top