Difference between revisions of "Relational and Logical Operators"

From Catglobe Wiki
Jump to: navigation, search
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
<img _fck_mw_template="true" _fckrealelement="0" _fckfakelement="true" src="http://wiki.catglobe.com/extensions/FCKeditor/fckeditor/editor/images/spacer.gif" class="FCK__MWTemplate">
 
 
 
=== Relational and Logical Operators  ===
 
=== 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.  
 
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>
  
Not equal to
+
{| 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" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
 
|- align="left" valign="top"
 
 
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
 
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
 
'''Operator'''  
 
'''Operator'''  
Line 17: Line 13:
 
'''Meaning'''  
 
'''Meaning'''  
  
|- align="left" valign="top"
+
|- valign="top" align="left"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
 
==  
 
==  
  
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
Equal to  
+
equa to<br>
  
|- align="left" valign="top"
+
|- valign="top" align="left"
 
| width="594" style="border:1px solid #010101;" | &nbsp;!=<br>  
 
| width="594" style="border:1px solid #010101;" | &nbsp;!=<br>  
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
 
Not equal to  
 
Not equal to  
  
|- align="left" valign="top"
+
|- valign="top" align="left"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
 
&gt;  
 
&gt;  
Line 36: Line 32:
 
Greater than  
 
Greater than  
  
|- align="left" valign="top"
+
|- valign="top" align="left"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
 
&lt;  
 
&lt;  
Line 43: Line 39:
 
Less than  
 
Less than  
  
|- align="left" valign="top"
+
|- valign="top" align="left"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
 
&gt;=  
 
&gt;=  
Line 50: Line 46:
 
Greater than or equal to  
 
Greater than or equal to  
  
|- align="left" valign="top"
+
|- valign="top" align="left"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
 
&lt;=  
 
&lt;=  
Line 61: 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.  
  
&lt;tbody&gt; &lt;/tbody&gt;
+
{| 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;=
 +
|}
  
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
+
<br> <br>
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
&nbsp;
 
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
The logical operators are shown next:  
'''array'''
 
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
+
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
'''bool'''
+
|- valign="top" align="left"
 +
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
 +
'''Operator'''  
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
+
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
'''number'''
+
'''Meaning'''  
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
+
|- valign="top" align="left"
'''question'''
+
| width="594" style="border:1px solid #010101;" |  
 +
&amp;&amp;
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
+
| width="594" style="border:1px solid #010101;" |  
'''range'''
+
Logical and
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
+
|- valign="top" align="left"
'''string'''
+
| width="594" style="border:1px solid #010101;" |  
 +
&#124;&#124;
  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
| width="594" style="border:1px solid #010101;" |  
'''datetime'''
+
Logical or
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
'''array'''
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
'''bool'''
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
'''number'''
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
'''question'''
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
'''range'''
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 
'''string'''
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
|- align="left" valign="top"
 
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
 
'''datetime'''
 
  
| width="149" style="border:1px solid #010101;" |
+
|- valign="top" align="left"
&nbsp;
+
| width="594" style="border:1px solid #010101;" | &nbsp;!
 
+
!
| width="149" style="border:1px solid #010101;" |  
+
Logical negation
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
&nbsp;
 
 
 
| width="149" style="border:1px solid #010101;" |
 
==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=
 
  
 
|}
 
|}
Line 268: Line 167:
 
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.  
  
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
+
[[Category:Operators]]
<tbody><tr align="left" valign="top">
 
<td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">Operator</strong></p>
 
</td>
 
<td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">Meaning</strong></p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;"><p class="bodytext">&amp;&amp;</p>
 
</td>
 
<td width="594" style="border:1px solid #010101;"><p class="bodytext">Logical and</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;"><p class="bodytext">||</p>
 
</td>
 
<td width="594" style="border:1px solid #010101;"><p class="bodytext">Logical or</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;"><p class="bodytext">!</p>
 
</td>
 
<td width="594" style="border:1px solid #010101;"><p class="bodytext">Logical negation</p>
 
</td>
 
</tr>
 
 
 
</tbody></table>
 
 
 
&lt;a _fcknotitle="true" href="Category:Operators"&gt;Operators&lt;/a&gt;
 

Latest revision as of 09: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.