Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Relational and Logical Operators: Difference between revisions

From Catglobe Wiki
Cg_pham (talk | contribs)
No edit summary
Cg_pham (talk | contribs)
No edit summary
Line 9: Line 9:
Not equal to  
Not equal to  


{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
{| 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 61: Line 61:
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.  


<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
&lt;tbody&gt; &lt;/tbody&gt;
<tbody><tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
</td>
|- align="left" valign="top"
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">array</strong></p>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
</td>
&nbsp;
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">bool</strong></p>
 
</td>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">number</strong></p>
'''array'''
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">question</strong></p>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
</td>
'''bool'''
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">range</strong></p>
 
</td>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">string</strong></p>
'''number'''
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">datetime</strong></p>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
</td>
'''question'''
</tr>
 
<tr align="left" valign="top">
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">array</strong></p>
'''range'''
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
</td>
'''string'''
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
'''datetime'''
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
|- align="left" valign="top"
</td>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</p>
'''array'''
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
| width="149" style="border:1px solid #010101;" |
</td>
&nbsp;
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
| width="149" style="border:1px solid #010101;" |
</tr>
&nbsp;
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">bool</strong></p>
| width="149" style="border:1px solid #010101;" |
</td>
&nbsp;
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
| width="149" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</p>
&nbsp;
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</p>
| width="149" style="border:1px solid #010101;" |
</td>
==,&nbsp;!=
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
| width="149" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
&nbsp;
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</p>
| width="149" style="border:1px solid #010101;" |
</td>
&nbsp;
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
|- align="left" valign="top"
</tr>
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
<tr align="left" valign="top">
'''bool'''
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">number</strong></p>
 
</td>
| width="149" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
&nbsp;
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</p>
| width="149" style="border:1px solid #010101;" |
</td>
==,&nbsp;!=
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=, &gt;, &lt;, &lt;=, &gt;=</p>
 
</td>
| width="149" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
==,&nbsp;!=
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</p>
| width="149" style="border:1px solid #010101;" |
</td>
&nbsp;
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
| width="149" style="border:1px solid #010101;" |
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
&nbsp;
</td>
 
</tr>
| width="149" style="border:1px solid #010101;" |
<tr align="left" valign="top">
==,&nbsp;!=
<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">==, !=</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">==, !=</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">==, !=</p>
</td>
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==, !=</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">==, !=</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">==, !=, &gt;, &lt;, &lt;=, &gt;=</p>
</td>
</tr>


</tbody></table>
| width="149" style="border:1px solid #010101;" |
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
&nbsp;
<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>
|- 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;" |
&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;!=, &gt;, &lt;, &lt;=, &gt;=
 
|}
 
<br>
 
The logical operators are shown next:<br>
 
{| 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;" |
&amp;&amp;
 
| width="594" style="border:1px solid #010101;" |
Logical and
 
|- align="left" valign="top"
| width="594" style="border:1px solid #010101;" |
&#124;&#124;
 
| 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.
The outcome of the relational and logical operators is a value of type bool.  


[[Category:Operators]]
[[Category:Operators]]

Revision as of 07:26, 5 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:

Not equal to

Operator

Meaning

==

Equal 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.

<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.