And: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
== Example (BASIC) ==
== Example (BASIC) ==


<pre>
<tabber>
Rem And Example
JavaScript=
'And performs logical and bitwise conjunction
<syntaxhighlight lang="JavaScript">
 
Dim Test1, Test2, x, y
x = 2
y = 7
Test1 = x > 0 And y < 10
Test2 = x > 0 And y > 10
Print "Logical:"
Print "  x > 0 And y < 10 = " & Test1
Print "  x > 0 And y > 10 = " & Test2
Print "Bitwise"
Print X Andb Y
</pre>
== Example (JavaScript) ==
<pre>
//And Example
//And Example
//And performs logical and bitwise conjunction
//And performs logical and bitwise conjunction
Line 41: Line 26:
NSB.Print("  x > 0 And y > 10 = "  +  Test2);
NSB.Print("  x > 0 And y > 10 = "  +  Test2);
NSB.Print("Bitwise");
NSB.Print("Bitwise");
NSB.Print(x  &  y);
NSB.Print(x  &  y);</syntaxhighlight>
</pre>
|-|
BASIC=
<syntaxhighlight lang="vb.net">
'Rem And Example
'And performs logical and bitwise conjunction
 
Dim Test1, Test2, x, y
x = 2
y = 7
Test1 = x > 0 And y < 10
Test2 = x > 0 And y > 10
Print "Logical:"
Print "  x > 0 And y < 10 = " & Test1
Print "  x > 0 And y > 10 = " & Test2
Print "Bitwise"
Print X Andb Y</syntaxhighlight>
</tabber>


== Output ==
== Output ==

Latest revision as of 13:21, 24 July 2019

result = x And y

result = x Andb y

Description

And (or && in JavaScript) returns the logical conjunction of two expressions. result is TRUE, if and only if both expressions x and y evaluate to TRUE, otherwise, result is FALSE.

Andb (or & in JavaScript) 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, otherwise it is set to 0.

Example (BASIC)

//And Example
//And performs logical and bitwise conjunction

var  Test1, Test2, x, y;
x = 2;
y = 7;
Test1 = x > 0 && y < 10;
Test2 = x > 0 && y > 10;
NSB.Print("Logical:");
NSB.Print("  x > 0 And y < 10 = "  +  Test1);
NSB.Print("  x > 0 And y > 10 = "  +  Test2);
NSB.Print("Bitwise");
NSB.Print(x  &  y);

'Rem And Example
'And performs logical and bitwise conjunction

Dim Test1, Test2, x, y
x = 2
y = 7
Test1 = x > 0 And y < 10
Test2 = x > 0 And y > 10
Print "Logical:"
Print "  x > 0 And y < 10 = " & Test1
Print "  x > 0 And y > 10 = " & Test2
Print "Bitwise"
Print X Andb Y

Output

Logical:
  x > 0 And y < 10 = True
  x > 0 And y > 10 = False
Bitwise:
2

Related Items

Eqv, Imp, Not, Or, Xor