Difference between revisions of "Relational and Logical Operators"
Line 3: | Line 3: | ||
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. | 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: | + | The relational operators are as follows:<br> |
− | + | {| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic" | |
− | + | |- valign="top" align="left" | |
− | {| width="1189" cellspacing="0" cellpadding="2" border="1 | ||
− | |- | ||
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''Operator''' | '''Operator''' | ||
Line 15: | Line 13: | ||
'''Meaning''' | '''Meaning''' | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
== | == | ||
Line 22: | Line 20: | ||
equa to<br> | equa to<br> | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | !=<br> | | width="594" style="border:1px solid #010101;" | !=<br> | ||
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
Not equal to | Not equal to | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
> | > | ||
Line 34: | Line 32: | ||
Greater than | Greater than | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
< | < | ||
Line 41: | Line 39: | ||
Less than | Less than | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
>= | >= | ||
Line 48: | Line 46: | ||
Greater than or equal to | Greater than or equal to | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
<= | <= | ||
Line 59: | Line 57: | ||
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. | ||
− | + | <br> | |
− | {| 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" |
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
| | ||
Line 87: | Line 85: | ||
'''datetime''' | '''datetime''' | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''array''' | '''array''' | ||
Line 112: | Line 110: | ||
| | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''bool''' | '''bool''' | ||
Line 137: | Line 135: | ||
| | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''number''' | '''number''' | ||
Line 162: | Line 160: | ||
| | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''question''' | '''question''' | ||
Line 187: | Line 185: | ||
| | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''range''' | '''range''' | ||
Line 212: | Line 210: | ||
| | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''string''' | '''string''' | ||
Line 237: | Line 235: | ||
| | ||
− | |- | + | |- valign="top" align="left" |
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''datetime''' | '''datetime''' | ||
Line 263: | Line 261: | ||
|} | |} | ||
+ | |||
+ | |||
The logical operators are shown next: | The logical operators are shown next: | ||
− | {| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101 | + | {| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101" |
− | |- | + | |- valign="top" align="left" |
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | | width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" | | ||
'''Operator''' | '''Operator''' | ||
Line 274: | Line 274: | ||
'''Meaning''' | '''Meaning''' | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
&& | && | ||
Line 281: | Line 281: | ||
Logical and | Logical and | ||
− | |- | + | |- valign="top" align="left" |
| width="594" style="border:1px solid #010101;" | | | width="594" style="border:1px solid #010101;" | | ||
|| | || | ||
Line 288: | Line 288: | ||
Logical or | Logical or | ||
− | |- | + | |- valign="top" align="left" |
− | | width="594" style="border:1px solid #010101;" | | + | | width="594" style="border:1px solid #010101;" | <br> |
! | ! | ||
− | Logical negation | + | Logical negation |
− | | width="594" style="border:1px solid #010101;" | | + | | width="594" style="border:1px solid #010101;" | <br> |
|} | |} | ||
+ | |||
+ | |||
The outcome of the relational and logical operators is a value of type bool. | The outcome of the relational and logical operators is a value of type bool. | ||
[[Category:Operators]] | [[Category:Operators]] |
Revision as of 07:52, 6 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:
Operator |
Meaning |
== |
equa to |
!= |
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.
|
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.