Comparison operator

from Wikipedia, the free encyclopedia

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 > < >= <= == !=, <> isO is notO
Lua > < >= <= == ~= nv nv
REXX > < >= <= =n ¬=, \=,<> ==s ¬==, \==
Modula , Oberon > < >= <= = #, <> nv nv
Shell ( test ) -gt -lt -ge -le -eqn -nen =s !=s
n always numerical comparison
O Object identity (see Python data model )
r identical or not identical for reference type →  reference type (Engl.)
s String comparison
t compares value and type
v Unconditional match between two entities
w equal to or not equal for value type →  valueType (Engl.)

See also