|
|
(14 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| | ''result'' = ''x'' And ''y'' |
|
| |
|
| '''Operator''' | | ''result'' = ''x'' Andb ''y'' |
|
| |
|
| result = x AND y
| | == Description == |
|
| |
|
| result = x ANDb y | | 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. |
|
| |
|
| '''Description'''
| | == Example (BASIC) == |
|
| |
|
| AND 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.
| | <tabber> |
| | JavaScript= |
| | <syntaxhighlight lang="JavaScript"> |
| | //And Example |
| | //And performs logical and bitwise conjunction |
|
| |
|
| ANDb 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.
| | 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);</syntaxhighlight> |
| | |-| |
| | BASIC= |
| | <syntaxhighlight lang="vb.net"> |
| | 'Rem And Example |
| | 'And performs logical and bitwise conjunction |
|
| |
|
| | | Dim Test1, Test2, x, y |
| | |
| '''Example'''
| |
| | |
| <pre>
| |
| REM AND Example
| |
| 'AND performs logical and bitwise conjunction
| |
| | |
| DIM Test1, Test2, x, y
| |
| x = 2 | | x = 2 |
| y = 7 | | y = 7 |
| Test1 = x > 0 AND y < 10 | | Test1 = x > 0 And y < 10 |
| Test2 = x > 0 AND y > 10 | | Test2 = x > 0 And y > 10 |
| PRINT "Logical:"
| | Print "Logical:" |
| PRINT " x > 0 AND y < 10 = " & Test1
| | Print " x > 0 And y < 10 = " & Test1 |
| PRINT " x > 0 AND y > 10 = " & Test2
| | Print " x > 0 And y > 10 = " & Test2 |
| PRINT "Bitwise"
| | Print "Bitwise" |
| PRINT X ANDb Y
| | Print X Andb Y</syntaxhighlight> |
| </pre> | | </tabber> |
|
| |
|
| '''Output'''
| | == Output == |
|
| |
|
| <pre> | | <pre> |
| Logical: | | Logical: |
| x > 0 AND y < 10 = True | | x > 0 And y < 10 = True |
| x > 0 AND y > 10 = False | | x > 0 And y > 10 = False |
| Bitwise: | | Bitwise: |
| 2 | | 2 |
| </pre> | | </pre> |
|
| |
|
| | == Related Items == |
| | |
| | [[eqv|Eqv]], [[imp|Imp]], [[not|Not]], [[or|Or]], [[xor|Xor]] |
|
| |
|
| '''Related Items'''
| | [[Category:Language Reference]] |
|
| |
|
| [[readfile|READFILE]], [[evq|EQV]], [[imp|IMP]], [[not|NOT]], [[or|OR]], [[xor|XOR]] | | [[Category:Logical Operators]] |
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