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 1: Line 1:
{{HelpFiles}}  
{{HelpFiles}}  


=== 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.  
Line 7: Line 7:
The relational operators are as follows:  
The relational operators are as follows:  


{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
Not equal to
 
{| 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;" |  
'''Operator'''
'''Operator'''  


| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
'''Meaning'''
'''Meaning'''  


|- align="left" valign="top"
|- align="left" valign="top"
| 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
Equal to  


|- align="left" valign="top"
|- align="left" valign="top"
| 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  
 
| width="594" style="border:1px solid #010101;" |
Not equal to


|- align="left" valign="top"
|- align="left" valign="top"
| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
&gt;
&gt;  


| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
Greater than
Greater than  


|- align="left" valign="top"
|- align="left" valign="top"
| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
&lt;
&lt;  


| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
Less than
Less than  


|- align="left" valign="top"
|- align="left" valign="top"
| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
&gt;=
&gt;=  


| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
Greater than or equal to
Greater than or equal to  


|- align="left" valign="top"
|- align="left" valign="top"
| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
&lt;=
&lt;=  


| width="594" style="border:1px solid #010101;" |  
| width="594" style="border:1px solid #010101;" |  
Less than or equal to
Less than or equal to  


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


{| 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="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |  
&nbsp;
&nbsp;  


| 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;" |  
&nbsp;
&nbsp;  


| width="149" style="border:1px solid #010101;" |  
| width="149" style="border:1px solid #010101;" |  
&nbsp;
&nbsp;  


| width="149" style="border:1px solid #010101;" |  
| width="149" style="border:1px solid #010101;" |  
&nbsp;
&nbsp;  


| width="149" style="border:1px solid #010101;" |  
| width="149" style="border:1px solid #010101;" |  
&nbsp;
&nbsp;  
 
| width="149" style="border:1px solid #010101;" | <br>
|}


| width="149" style="border:1px solid #010101;" |
==,&nbsp;!=
==,&nbsp;!=



Revision as of 07:21, 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.

 

array

bool

number

question

range

string

datetime

array

 

 

 

 


=, !

| width="149" style="border:1px solid #010101;" |  

| width="149" style="border:1px solid #010101;" |  

|- align="left" valign="top" | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | 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;" |  

|- align="left" valign="top" | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | 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;" |  

|- align="left" valign="top" | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | 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;" |  

|- align="left" valign="top" | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | 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;" |  

|- align="left" valign="top" | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | 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;" |  

|- align="left" valign="top" | width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" | 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;" |

=, !=, >, <, <=, >

|}

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.