Ordinal Data - Comparison Operator (Order, Equality)
About
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
Usage
Sort
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
Properties
Order of precedence
order of precedence - All comparison operators have the same priority, which is lower than that of all operator mathematical operators
Chain
Comparisons may be chained.
For example, a < b == c tests whether:
- a < b
- and moreover b == c
Combination
Comparisons may be combined using the Boolean operators and and or to from a predicate (boolean expression)
Relation
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
Order relation, including strict orders:
- greater than or equal to
- less than or equal to
- divides (evenly)
- is a subset of
| Operation | Description |
|---|---|
| < | 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 |
Equivalence
The equal operators model an equivalence relationship
