// Xor Example
/* Xor performs exclusive disjunctions */
var Test1, Test2, x, y;
x = 2;
y = 9;
Test1 = ((x > 0) ^ (y < 10)) == 1;
Test2 = ((x > 0) ^ (y > 10)) == 1;
NSB.Print("Logical:");
NSB.Print(" (x > 0) Xor (y < 10) = " + Test1.toString());
NSB.Print(" (x > 0) Xor (y > 10) = " + Test2.toString());
Xor: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 7: | Line 7: | ||
== Example == | == Example == | ||
< | <tabber> | ||
JavaScript= | |||
<syntaxhighlight lang="JavaScript"> | |||
// Xor Example | |||
/* Xor performs exclusive disjunctions */ | |||
var Test1, Test2, x, y; | |||
x = 2; | |||
y = 9; | |||
Test1 = ((x > 0) ^ (y < 10)) == 1; | |||
Test2 = ((x > 0) ^ (y > 10)) == 1; | |||
NSB.Print("Logical:"); | |||
NSB.Print(" (x > 0) Xor (y < 10) = " + Test1.toString()); | |||
NSB.Print(" (x > 0) Xor (y > 10) = " + Test2.toString()); | |||
</syntaxhighlight> | |||
|-| | |||
BASIC= | |||
<syntaxhighlight lang="vb.net"> | |||
Rem Xor Example | Rem Xor Example | ||
'Xor performs exclusive disjunctions | 'Xor performs exclusive disjunctions | ||
Dim Test1, Test2, x, y | Dim Test1, Test2, x, y | ||
x = 2 | x = 2 | ||
y = 9 | y = 9 | ||
Test1 = x > 0 Xor y < 10 | Test1 = (x > 0) Xor (y < 10) | ||
Test2 = x > 0 Xor y > 10 | Test2 = (x > 0) Xor (y > 10) | ||
Print "Logical:" | Print "Logical:" | ||
Print " x > 0 Xor y < 10 = " & CStr(Test1) | Print " (x > 0) Xor (y < 10) = " & CStr(Test1) | ||
Print " x > 0 Xor y > 10 = " & CStr(Test2) | Print " (x > 0) Xor (y > 10) = " & CStr(Test2) | ||
</ | </syntaxhighlight> | ||
</tabber> | |||
== Output == | == Output == | ||
Line 24: | Line 43: | ||
<pre> | <pre> | ||
Logical: | Logical: | ||
x > 0 Xor y < 10 = False | (x > 0) Xor (y < 10) = False | ||
x > 0 Xor y > 10 = True | (x > 0) Xor (y > 10) = True | ||
</pre> | </pre> | ||
== Related Items == | == Related Items == | ||
[[and| | [[and|And]], [[eqv|Eqv]], [[imp|Imp]], [[not|Not]], [[or|Or]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
[[Category:Logical Operators]] | [[Category:Logical Operators]] |
Latest revision as of 23:41, 24 July 2019
result = x Xor y
Description
Xor returns the logical, exclusive disjunction of two expressions. result is TRUE, if and only if one of the expressions x and y evaluate to TRUE, otherwise, result is FALSE.
Example
Rem Xor Example
'Xor performs exclusive disjunctions
Dim Test1, Test2, x, y
x = 2
y = 9
Test1 = (x > 0) Xor (y < 10)
Test2 = (x > 0) Xor (y > 10)
Print "Logical:"
Print " (x > 0) Xor (y < 10) = " & CStr(Test1)
Print " (x > 0) Xor (y > 10) = " & CStr(Test2)
Output
Logical: (x > 0) Xor (y < 10) = False (x > 0) Xor (y > 10) = True