Comparison operator
A comparison operator (also known as a relational operator ) is a two-digit logical operator , i.e. an operator that is applied to two arguments and delivers a truth value . Comparison operators are mainly used in mathematical equations or inequalities and in logical expressions in programming languages and are usually represented by comparison symbols.
In programming languages, comparison operators are mostly used in loops and conditions . After a comparison there is usually a program branch .
operator | ||||||||
---|---|---|---|---|---|---|---|---|
greater than n |
smaller than n |
greater than or equal to n |
less than or equal to n |
equal | unequal | identical | not identical |
|
mathematical sign |
> | < | ≥ | ≤ | = | ≠ | ≡ v | ≢ |
APL | > |
< |
≥ |
≤ |
= |
≠ |
≡ |
≢
|
Fortran | .GT. |
.LT. |
.GE. |
.LE. |
.EQ. |
.NE. |
nv | nv |
Pascal , SQL , BASIC | > |
< |
>= |
<= |
= |
<> |
nv | nv |
C , C ++ , C # , Perl | > |
< |
>= |
<= |
== |
!= |
nv | nv |
Java | > |
< |
>= |
<= |
== w
|
!= w
|
== r
|
!= r
|
JavaScript | > |
< |
>= |
<= |
== |
!= |
=== t
|
!== t
|
PHP , raku | > |
< |
>= |
<= |
== |
!= , <>
|
=== t
|
!== t
|
python | > |
< |
>= |
<= |
== |
!= , <>
|
is O
|
is not O
|
Lua | > |
< |
>= |
<= |
== |
~= |
nv | nv |
REXX | > |
< |
>= |
<= |
= n
|
¬= , \= ,<>
|
== s
|
¬== , \==
|
Modula , Oberon | > |
< |
>= |
<= |
= |
# , <>
|
nv | nv |
Shell ( test ) |
-gt
|
-lt
|
-ge
|
-le
|
-eq n
|
-ne n
|
= s
|
!= s
|
n always numerical comparison
O Object identity (see Python data model )
v Unconditional match between two entities