Comparison Operators

You use operators to compare data items. All of these operators return a Boolean value (true or false).

You can use comparison operators with all data types, that is, you can use them to compare numbers, text strings, Boolean values, etc. You can also use them to compare lists and matrices.

Comparison Operators

Operator Definition
Equal x==y Returns true if x and y are identical. Otherwise, it returns false.
Not Equal x!=y Returns true if x and y are not identical. Otherwise, it returns false.
Less Than x<y Returns true if x is less than y. Otherwise, it returns false.
Greater than x>y Returns true if x is greater than y. Otherwise, it returns false.
Less Than or Equal x<=y Returns true if x is either less than or equal to y. Otherwise, it returns false.
Greater than or equal x>=y Returns true if x is either greater than or equal to y. Otherwise, it returns false.