Difference between revisions of "Relational and Logical Operators"

From Catglobe Wiki
Jump to: navigation, search
 
(7 intermediate revisions by the same user not shown)
Line 57: 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="100%" border="1" cellpadding="1" cellspacing="1" align="left"
 
+
|-
{| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic"
+
|  
|- valign="top" align="left"
+
| array  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
| bool  
&nbsp;
+
| number  
 
+
| question  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
| range  
'''array'''
+
| string  
 
+
| datetime
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
|-
'''bool'''
+
| array  
 
+
|  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
|  
'''number'''
+
|  
 
+
|  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
| ==,&nbsp;!=  
'''question'''
+
|  
 
+
|  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
|-
'''range'''
+
| bool  
 
+
|  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
| ==,&nbsp;!=  
'''string'''
+
| ==,&nbsp;!=  
 
+
|  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
|  
'''datetime'''
+
| ==,&nbsp;!=  
 
+
|  
|- valign="top" align="left"
+
|-
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
| number  
'''array'''
+
|  
 
+
| ==,&nbsp;!=  
| width="149" style="border:1px solid #010101;" |  
+
| ==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=  
&nbsp;
+
|  
 
+
| ==,&nbsp;!=  
| width="149" style="border:1px solid #010101;" |  
+
|  
&nbsp;
+
|  
 
+
|-
| width="149" style="border:1px solid #010101;" |  
+
| question  
&nbsp;
+
|  
 
+
|  
| width="149" style="border:1px solid #010101;" |
+
|  
&nbsp;
+
|  
 
+
|  
| width="149" style="border:1px solid #010101;" |
+
|  
= =,&nbsp;! =
+
|  
 
+
|-
| width="149" style="border:1px solid #010101;" |  
+
| range  
&nbsp;
+
| ==,!=  
 
+
|  
| width="149" style="border:1px solid #010101;" |  
+
| ==,&nbsp;!=  
&nbsp;
+
|  
 
+
|  
|- valign="top" align="left"
+
|  
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
+
|  
'''bool'''
+
|-
 
+
| string  
| width="149" style="border:1px solid #010101;" |  
+
|  
&nbsp;
+
| ==,&nbsp;!=  
 
+
| ==,&nbsp;!=  
| width="149" style="border:1px solid #010101;" |  
+
|  
= =,&nbsp;! =
+
|  
 
+
| ==,&nbsp;!=  
| width="149" style="border:1px solid #010101;" |  
+
|  
= =,&nbsp;! =
+
|-
 
+
| 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;!=, &gt;, &lt;, &lt;=, &gt;=
= =,&nbsp;! =
 
 
 
| width="149" style="border:1px solid #010101;" |  
 
&nbsp;
 
 
 
|- valign="top" align="left"
 
| 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;
 
 
 
|- valign="top" align="left"
 
| 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;
 
 
 
|- valign="top" align="left"
 
| 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;
 
 
 
|- valign="top" align="left"
 
| 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;
 
 
 
|- valign="top" align="left"
 
| 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> <br>
  
 
The logical operators are shown next:  
 
The logical operators are shown next:  
Line 289: Line 159:
  
 
|- valign="top" align="left"
 
|- valign="top" align="left"
| width="594" style="border:1px solid #010101;" | <br>
+
| width="594" style="border:1px solid #010101;" | &nbsp;!
 
!  
 
!  
&nbsp; Logical negation  
+
Logical negation
  
| 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]]

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.