Difference between revisions of "Relational and Logical Operators"
Line 1: | Line 1: | ||
− | |||
=== Relational and Logical Operators === | === Relational and Logical Operators === | ||
Line 8: | Line 7: | ||
Not equal to | Not equal to | ||
− | {| width="1189" cellspacing="0" cellpadding="2" border="1 | + | {| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic" |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
Line 21: | Line 20: | ||
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
− | + | <br> | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
Line 60: | Line 59: | ||
Those relational operators cannot be applied to all data types and in some cases, two values of different types cannot be compared to each other. | Those relational operators cannot be applied to all data types and in some cases, two values of different types cannot be compared to each other. | ||
− | <tbody> </tbody> | + | <tbody> </tbody> |
− | {| width="1189" cellspacing="0" cellpadding="2" border="1 | + | {| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic" |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''array''' | + | '''array''' |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''bool''' | + | '''bool''' |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''number''' | + | '''number''' |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''question''' | + | '''question''' |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''range''' | + | '''range''' |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''string''' | + | '''string''' |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''datetime''' | + | '''datetime''' |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''array''' | + | '''array''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''bool''' | + | '''bool''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''number''' | + | '''number''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, !=, >, <, <=, >= | + | = =, !=, >, <, <=, > = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''question''' | + | '''question''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''range''' | + | '''range''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''string''' | + | '''string''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, != | + | = =, ! = |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
− | '''datetime''' | + | '''datetime''' |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | | + | |
| width="149" style="border:1px solid #010101;" | | | width="149" style="border:1px solid #010101;" | | ||
− | ==, !=, >, <, <=, >= | + | = =, !=, >, <, <=, > = |
|} | |} | ||
− | The logical operators are shown next: | + | The logical operators are shown next: |
+ | |||
+ | __ | ||
+ | |||
+ | {| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101" | ||
+ | |- align="left" valign="top" | ||
+ | | width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
+ | '''Operator''' | ||
+ | |||
+ | | width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
+ | '''Meaning''' | ||
− | + | |- align="left" valign="top" | |
− | + | | width="594" style="border:1px solid #010101;" | | |
− | + | && | |
− | + | ||
− | + | | width="594" style="border:1px solid #010101;" | | |
− | + | Logical and | |
− | + | ||
− | + | |- align="left" valign="top" | |
− | + | | width="594" style="border:1px solid #010101;" | | |
− | + | || | |
− | + | ||
− | + | | width="594" style="border:1px solid #010101;" | | |
− | + | Logical or | |
− | + | ||
− | + | |- align="left" valign="top" | |
− | + | | width="594" style="border:1px solid #010101;" | | |
− | + | ! | |
− | + | ||
− | + | | width="594" style="border:1px solid #010101;" | | |
− | + | Logical negation | |
− | + | ||
− | + | |} | |
− | |||
− | |||
− | |||
− | + | The outcome of the relational and logical operators is a value of type bool. | |
− | |||
[[Category:Operators]] | [[Category:Operators]] |
Revision as of 08:39, 5 January 2012
Contents
Relational and Logical Operators
Relational refers to the relationships that values can have with one another, and logical refers to the ways in which true and false values can be connected together. Since the relational operators produce true or false results, they are often used in combination with the logical operators.
The relational operators are as follows:
Not equal to
Operator |
Meaning |
== |
|
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |
Those relational operators cannot be applied to all data types and in some cases, two values of different types cannot be compared to each other.
<tbody> </tbody>
|
array |
bool |
number |
question |
range |
string |
datetime |
array |
|
|
|
|
=, ! |
|
|
bool |
|
=, ! |
=, ! |
|
|
=, ! |
|
number |
|
=, ! |
=, !=, >, <, <=, > |
|
=, ! |
|
|
question |
|
|
|
|
|
|
|
range |
=, ! |
|
=, ! |
|
|
|
|
string |
|
=, ! |
=, ! |
|
|
=, ! |
|
datetime |
|
|
|
|
|
|
=, !=, >, <, <=, > |
The logical operators are shown next:
__
Operator |
Meaning | |
&& |
Logical and | |
|| |
Logical or | |
Logical negation |
The outcome of the relational and logical operators is a value of type bool.