Next: , Previous: , Up: Operators   [Contents][Index]

6.3.6 Binary Relational Operators

Binary relational operators are defined for (real or complex) scalars (Scalars) and numerical arrays (Arrays) and for strings (Strings). They compare the values of the operands, and return either a 1 or a 0, depending on whether the operands do or do not posess the relation implied by the operator. For string operands, relations are tested based on the byte codes used internally by your computer to represent the characters. Most computers nowadays use ASCII code for that, but some IBM mainframes use a different format. In both of these formats, letters are compared based on alphabetical order. If the second string is equal to the first one with some more characters appended, then the second string is considered to lie closer to the end of the alphabet than the first string. When testing for relative order involving one or more complex numbers, an ordering based on projection on 1+i is used, such that the usual ordering holds on the real and imaginary axes of the complex plane (e.g., 1 GT -1 and #i GT -#i; see Complex Numbers.

The following relational operators are available:

Equal To

x EQ y returns 1 if x is equal to y.

Unequal To

x NE y returns 1 if x is unequal to y.

Greater Than

x GT y returns 1 if x is greater than y.

Greater Than Or Equal To

x GE y returns 1 if x is greater than or equal to y.

Less Than

x LT y returns 1 if x is less than y.

Less Than Or Equal To

x LE y returns 1 if x is less than or equal to y.

For example, the following relations are all true:

6 GT 3
-6 LE -3
'Jill' LT 'John'
'Apple' NE 'Apples'
'Apples' GT 'Apple'

Next: , Previous: , Up: Operators   [Contents][Index]