Difference between revisions of "Relational and Logical Operators"

From Catglobe Wiki
Jump to: navigation, search
(Undo revision 23319 by Cg pham (talk))
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
<p><span class="fck_mw_template">{{HelpFiles}}</span>
+
=== Relational and Logical Operators  ===
</p>
 
<h3> Relational and Logical Operators  </h3>
 
<p>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.
 
</p><p>The relational operators are as follows:
 
</p><p>Not equal to
 
</p>
 
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
 
  
<tr align="left" valign="top">
+
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.
<td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;">
 
<p><b>Operator</b>
 
</p>
 
</td><td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;">
 
<p><b>Meaning</b>
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>==
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Equal to  
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;"> &nbsp;!=<br />
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Not equal to  
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&gt;
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Greater than
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&lt;
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Less than
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&gt;=
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Greater than or equal to
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&lt;=
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Less than or equal to
 
</p>
 
</td></tr></table>
 
<p>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.  
 
</p>
 
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
 
&lt;tbody&gt;<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">array</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">bool</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">number</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">question</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">range</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">string</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">datetime</strong></p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">array</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">bool</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">number</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">question</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">range</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">string</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">datetime</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=</p>
 
</td>
 
</tr>
 
  
&lt;/tbody&gt;</table>
+
The relational operators are as follows:<br>
<p>The outcome of the relational and logical operators is a value of type bool.
+
 
</p><a _fcknotitle="true" href="Category:Operators">Operators</a>
+
{| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic"
 +
|- valign="top" align="left"
 +
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''Operator'''
 +
 
 +
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''Meaning'''
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
==
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
equa to<br>
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" | &nbsp;!=<br>
 +
| width="594" style="border:1px solid #010101;" |
 +
Not equal to
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
&gt;
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Greater than
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
&lt;
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Less than
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
&gt;=
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Greater than or equal to
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
&lt;=
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
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.
 +
 
 +
{| width="100%" border="1" cellpadding="1" cellspacing="1" align="left"
 +
|-
 +
|
 +
| array
 +
| bool
 +
| number
 +
| question
 +
| range
 +
| string
 +
| datetime
 +
|-
 +
| array
 +
|
 +
|
 +
|
 +
|
 +
| ==,&nbsp;!=
 +
|
 +
|
 +
|-
 +
| bool
 +
|
 +
| ==,&nbsp;!=
 +
| ==,&nbsp;!=
 +
|
 +
|
 +
| ==,&nbsp;!=
 +
|
 +
|-
 +
| number
 +
|
 +
| ==,&nbsp;!=
 +
| ==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=
 +
|
 +
| ==,&nbsp;!=
 +
|
 +
|
 +
|-
 +
| question
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|-
 +
| range
 +
| ==,!=
 +
|
 +
| ==,&nbsp;!=
 +
|
 +
|
 +
|
 +
|
 +
|-
 +
| string
 +
|
 +
| ==,&nbsp;!=
 +
| ==,&nbsp;!=
 +
|
 +
|
 +
| ==,&nbsp;!=
 +
|
 +
|-
 +
| datetime
 +
|
 +
|
 +
|
 +
|
 +
|
 +
|
 +
| ==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=
 +
|}
 +
 
 +
<br> <br>  
 +
 
 +
The logical operators are shown next:
 +
 
 +
{| 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;" |
 +
'''Operator'''
 +
 
 +
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''Meaning'''
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
&amp;&amp;
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Logical and
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" |
 +
&#124;&#124;
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Logical or
 +
 
 +
|- valign="top" align="left"
 +
| width="594" style="border:1px solid #010101;" | &nbsp;!
 +
!
 +
Logical negation
 +
 
 +
|}
 +
 
 +
The outcome of the relational and logical operators is a value of type bool.  
 +
 
 +
[[Category:Operators]]

Latest revision as of 08:16, 6 January 2012

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.