A comparison operator is a class of operators that model:
- a order
- or a equivalence relationship
A comparison operator test the order relationship between two operands and returns a Boolean.
The result of a comparison is a Boolean
Comparison Operator are tiddly coupled:
- with the order
in order to sort data.
Condition / Filter
Comparison Operator are used in predicate (condition) in order to filter
Order of precedence
order of precedence - All comparison operators have the same priority, which is lower than that of all operator mathematical operators
Comparisons may be chained.
For example, a < b == c tests whether:
- a < b
- and moreover b == c
Comparisons may be combined using the Boolean operators and and or to from a predicate (boolean expression)
Comparison operator models two kind of relation:
Binary relation are used in many branches of mathematics to model this relation. See Logical Data Modeling - Binary Relation.
Order relation, including strict orders:
- greater than or equal to
- less than or equal to
- divides (evenly)
- is a subset of
|<||strictly less than|
|<=||less than or equal|
|>||strictly greater than|
|>=||greater than or equal|
|in||check whether a value occurs in a list|
|not in||check whether a value does not occur in a list|
The equal operators model an equivalence relationship