Eqv: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Brendon (talk | contribs)
Created page with "'''Operator''' ''result = x EQV y'' '''Description''' EQV returns the logical equivalence of two expressions. ''result'' is TRUE, if both expressions ''x'' and ''y'' evalua..."
 
No edit summary
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Operator'''
== Operator ==


''result = x EQV y''
''result = x Eqv y''


'''Description'''
== Description ==


EQV returns the logical equivalence of two expressions. ''result'' is TRUE, if both expressions ''x'' and ''y'' evaluate to TRUE or both expressions ''x'' and ''y'' evaluate to FALSE, otherwise, result is FALSE.
Eqv returns the logical equivalence of two expressions. ''result'' is TRUE, if both expressions ''x'' and ''y'' evaluate to TRUE or both expressions ''x'' and ''y'' evaluate to FALSE, otherwise, result is FALSE.


EQV also does a bitwise comparison of two numeric expressions. Each bit in result is set to 1 if both corresponding bits in ''x'' and ''y'' are 1 or both corresponding bits in ''x'' and ''y'' are 0, otherwise it is set to 0.
Eqv also does a bitwise comparison of two numeric expressions. Each bit in result is set to 1 if both corresponding bits in ''x'' and ''y'' are 1 or both corresponding bits in ''x'' and ''y'' are 0, otherwise it is set to 0.


'''Example'''
== Example ==


<pre>
<tabber>
REM EQV Example
JavaScript=
'EQV performs logical and bitwiseequivalence
<syntaxhighlight lang="JavaScript">
DIM Test1, Test2, Test3, x, y
// Eqv Example
/* Eqv performs logical and bitwise equivalence */
 
function eqvFunc(a,b) {
  if (a==true && b==true || a==false && b==false) {
    return true;
  } else {
    return false;
  }
}
 
var Test1, Test2, Test3, x, y;
x = 4;
y = 9;
Test1 = eqvFunc(x < 0,y < 10);
Test2 = eqvFunc(x > 0,y > 10);
Test3 = eqvFunc(x < 0,y > 10);
NSB.Print("Logical:");
NSB.Print("  x < 0 Eqv y < 10 = " + Test1);
NSB.Print("  x > 0 Eqv y > 10 = " + Test2);
NSB.Print("  x < 0 Eqv y > 10 = " + Test3);
</syntaxhighlight>
|-|
BASIC=
<syntaxhighlight lang="vb.net">
Rem Eqv Example
'Eqv performs logical and bitwise equivalence
Dim Test1, Test2, Test3, x, y
x = 4
x = 4
y = 9
y = 9
Test1 = x < 0 EQV y < 10
Test1 = x < 0 Eqv y < 10
Test2 = x > 0 EQV y > 10
Test2 = x > 0 Eqv y > 10
Test3 = x < 0 EQV y > 10
Test3 = x < 0 Eqv y > 10
PRINT "Logical:"
Print "Logical:"
PRINT "  x < 0 EQV y < 10 = " & Test1
Print "  x < 0 Eqv y < 10 = " & Test1
PRINT "  x > 0 EQV y > 10 = " & Test2
Print "  x > 0 Eqv y > 10 = " & Test2
PRINT "  x < 0 EQV y > 10 = " & Test3
Print "  x < 0 Eqv y > 10 = " & Test3
</pre>
</syntaxhighlight>
</tabber>


'''Output'''
== Output ==


<pre>
<pre>
Logical:
Logical:
   x < 0 EQV y < 10 = False
   x < 0 Eqv y < 10 = False
   x > 0 EQV y > 10 = False
   x > 0 Eqv y > 10 = False
   x < 0 EQV y > 10 = True
   x < 0 Eqv y > 10 = True
</pre>
</pre>


'''Related Items'''
== Related Items ==
 
[[and|And]], [[imp|Imp]], [[not|Not]], [[or|Or]], [[xor|Xor]]
 
[[Category:Language Reference]]


[[and|AND], [[imp|IMP]], [[not|NOT]], [[or|OR]], [[xor|XOR]]
[[Category:Logical Operators]]

Latest revision as of 14:17, 24 July 2019

Operator

result = x Eqv y

Description

Eqv returns the logical equivalence of two expressions. result is TRUE, if both expressions x and y evaluate to TRUE or both expressions x and y evaluate to FALSE, otherwise, result is FALSE.

Eqv also does a bitwise comparison of two numeric expressions. Each bit in result is set to 1 if both corresponding bits in x and y are 1 or both corresponding bits in x and y are 0, otherwise it is set to 0.

Example

// Eqv Example
/* Eqv performs logical and bitwise equivalence */

function eqvFunc(a,b) {
  if (a==true && b==true || a==false && b==false) {
    return true;
  } else {
    return false;
  }
}

var Test1, Test2, Test3, x, y;
x = 4;
y = 9;
Test1 = eqvFunc(x < 0,y < 10);
Test2 = eqvFunc(x > 0,y > 10);
Test3 = eqvFunc(x < 0,y > 10);
NSB.Print("Logical:");
NSB.Print("  x < 0 Eqv y < 10 = " + Test1);
NSB.Print("  x > 0 Eqv y > 10 = " + Test2);
NSB.Print("  x < 0 Eqv y > 10 = " + Test3);

Rem Eqv Example
'Eqv performs logical and bitwise equivalence
Dim Test1, Test2, Test3, x, y
x = 4
y = 9
Test1 = x < 0 Eqv y < 10
Test2 = x > 0 Eqv y > 10
Test3 = x < 0 Eqv y > 10
Print "Logical:"
Print "  x < 0 Eqv y < 10 = " & Test1
Print "  x > 0 Eqv y > 10 = " & Test2
Print "  x < 0 Eqv y > 10 = " & Test3

Output

Logical:
  x < 0 Eqv y < 10 = False
  x > 0 Eqv y > 10 = False
  x < 0 Eqv y > 10 = True

Related Items

And, Imp, Not, Or, Xor