Next: Binary Bounding, Previous: Binary Conditionals, Up: Operators [Contents][Index]
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:
x EQ y
returns 1 if x
is equal to y
.
x NE y
returns 1 if x
is unequal to y
.
x GT y
returns 1 if x
is greater than y
.
x GE y
returns 1 if x
is greater than or equal to y
.
x LT y
returns 1 if x
is less than y
.
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: Binary Bounding, Previous: Binary Conditionals, Up: Operators [Contents][Index]