Difference between revisions of "XOR (boolean)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Cyperium
(Created page with '{{KW|XOR (boolean)|XOR}} evaluates two expressions and if either of them is True then it returns True, if both of them are True then it returns False, if both of them are False t…')
 
imported>Clippy
m
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{KW|XOR (boolean)|XOR}} evaluates two expressions and if either of them is True then it returns True, if both of them are True then it returns False, if both of them are False then it returns False.
+
{{KW|XOR (boolean)|XOR}} evaluates two conditions and if either of them is True then it returns True, if both of them are True then it returns False, if both of them are False then it returns False.
  
  
Line 8: Line 8:
 
{{PageDescription}}
 
{{PageDescription}}
 
* Either {{Parameter|condition}} or {{Parameter|condition2}} must be True for the evaluation to return True.
 
* Either {{Parameter|condition}} or {{Parameter|condition2}} must be True for the evaluation to return True.
* It is called ''extended OR'' because the conditions cannot both be True for it to return True like the {{KW|OR (boolean)|OR}} evaluation.
+
* It is called '''"exclusive OR"''' because the conditions cannot both be True for it to return True like the {{KW|OR (boolean)|OR}} evaluation.
 
* {{Parameter|condition}} and {{Parameter|condition2}} can themselves contain XOR evaluations.
 
* {{Parameter|condition}} and {{Parameter|condition2}} can themselves contain XOR evaluations.
 +
 +
 +
{{Template:RelationalTable}}
  
  
Line 23: Line 26:
 
{{Cl|PRINT}} "Thank you for your honesty!"
 
{{Cl|PRINT}} "Thank you for your honesty!"
 
{{Cl|ELSE}}
 
{{Cl|ELSE}}
{{Cl|PRINT}} "You can't both have won!"
+
{{Cl|PRINT}} "You can't both have won (or lost)!"
 
{{Cl|END IF}}
 
{{Cl|END IF}}
  
 
{{CodeEnd}}
 
{{CodeEnd}}
 
+
{{OutputStart}}
 +
You can't both have won (or lost)!
 +
{{OutputEnd}}
  
  
 
{{PageSeeAlso}}
 
{{PageSeeAlso}}
* {{KW|OR (boolean)}}, {{KW|AND (boolean)}}
+
* [[OR (boolean)]], [[AND (boolean)]]
* {{KW|IF...THEN}}
+
* [[IF...THEN]]
  
  
 
{{PageNavigation}}
 
{{PageNavigation}}

Latest revision as of 20:21, 19 December 2011

XOR evaluates two conditions and if either of them is True then it returns True, if both of them are True then it returns False, if both of them are False then it returns False.


Syntax

condition XOR condition2


Description

  • Either condition or condition2 must be True for the evaluation to return True.
  • It is called "exclusive OR" because the conditions cannot both be True for it to return True like the OR evaluation.
  • condition and condition2 can themselves contain XOR evaluations.


Relational Operators:
Symbol Condition Example Usage
= Equal IF a = b THEN
<> NOT equal IF a <> b THEN
< Less than IF a < b THEN
> Greater than IF a > b THEN
<= Less than or equal IF a <= b THEN
>= Greater than or equal IF a >= b THEN


Examples

Example: Dilemma...

True = NOT False AndersWon = True PeterWon = True IF AndersWon = True XOR PeterWon = True THEN PRINT "Thank you for your honesty!" ELSE PRINT "You can't both have won (or lost)!" END IF

You can't both have won (or lost)!


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page