Difference between revisions of "Relational and Logical Operators"

From Catglobe Wiki
Jump to: navigation, search
Line 5: Line 5:
 
The relational operators are as follows:  
 
The relational operators are as follows:  
  
Not equal to
 
  
{| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic"
+
 
 +
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
 
|- 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 20: Line 20:
  
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
<br>  
+
equa to<br>  
  
 
|- align="left" valign="top"
 
|- align="left" valign="top"
Line 61: Line 61:
 
&lt;tbody&gt; &lt;/tbody&gt;  
 
&lt;tbody&gt; &lt;/tbody&gt;  
  
{| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic"
+
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
 
|- 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;" |  
Line 104: Line 104:
  
 
| 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;" |  
Line 120: Line 120:
  
 
| 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;" |  
Line 132: Line 132:
  
 
| 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;" |  
Line 145: Line 145:
  
 
| 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;!=, &gt;, &lt;, &lt;=, &gt; =
+
= =,&nbsp;!=, &gt;, &lt;, &lt;=, &gt; =
  
 
| width="149" style="border:1px solid #010101;" |  
 
| width="149" style="border:1px solid #010101;" |  
Line 154: Line 154:
  
 
| 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;" |  
Line 192: Line 192:
  
 
| 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;" |  
Line 198: Line 198:
  
 
| 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;" |  
Line 220: Line 220:
  
 
| 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;" |  
Line 232: Line 232:
  
 
| 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;" |  
Line 260: Line 260:
  
 
| width="149" style="border:1px solid #010101;" |  
 
| width="149" style="border:1px solid #010101;" |  
= =,&nbsp;!=, &gt;, &lt;, &lt;=, &gt; =
+
= =,&nbsp;!=, &gt;, &lt;, &lt;=, &gt; =
  
 
|}
 
|}
Line 266: Line 266:
 
The logical operators are shown next:  
 
The logical operators are shown next:  
  
__
+
{| width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic"
 
 
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
 
 
|- 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;" |  
&amp;&amp;
+
&amp;&amp;  
  
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
Logical and
+
Logical and  
  
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
&#124;&#124;
+
&#124;&#124;  
  
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
Logical or
+
Logical or  
  
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
!
+
!  
 +
&nbsp; Logical negation
  
 
| width="594" style="border:1px solid #010101;" |  
 
| width="594" style="border:1px solid #010101;" |  
Logical negation
 
 
 
|}
 
|}
  

Revision as of 09:41, 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:


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.

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