Difference between revisions of "Relational and Logical Operators"
Line 60: | Line 60: | ||
|- | |- | ||
| | | | ||
− | | array | + | | array |
− | | bool | + | | bool |
− | | number | + | | number |
− | | question | + | | question |
− | | range | + | | range |
− | | string | + | | string |
| datetime | | datetime | ||
|- | |- | ||
− | | array | + | | array |
− | |||
| | | | ||
| | | | ||
| | | | ||
| | | | ||
+ | | ==, != | ||
| | | | ||
| | | | ||
|- | |- | ||
− | | bool | + | | bool |
| | | | ||
+ | | ==, != | ||
| ==, != | | ==, != | ||
| | | | ||
| | | | ||
+ | | ==, != | ||
| | | | ||
+ | |- | ||
+ | | number | ||
| | | | ||
− | | | + | | ==, != |
− | | | + | | ==, !=, >, <, <=, >= |
− | |||
| | | | ||
| ==, != | | ==, != | ||
− | |||
− | |||
− | |||
| | | | ||
| | | | ||
|- | |- | ||
− | | question | + | | question |
| | | | ||
| | | | ||
Line 104: | Line 104: | ||
| | | | ||
|- | |- | ||
− | | range | + | | range |
− | | ==,!= | + | | ==,!= |
− | |||
| | | | ||
+ | | ==, != | ||
| | | | ||
| | | | ||
Line 113: | Line 113: | ||
| | | | ||
|- | |- | ||
− | | string | + | | string |
| | | | ||
+ | | ==, != | ||
| ==, != | | ==, != | ||
| | | | ||
| | | | ||
− | | | + | | ==, != |
− | |||
| | | | ||
|- | |- | ||
− | | datetime | + | | datetime |
− | |||
| | | | ||
| | | | ||
Line 130: | Line 129: | ||
| | | | ||
| | | | ||
+ | | ==, !=, >, <, <=, >= | ||
|} | |} | ||
Revision as of 08:14, 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.