The Strictly Equal And Equal Operators; Using Comparison Expressions - IBM TSO/E REXX User Manual

Table of Contents

Advertisement

Comparison operators can compare numbers or strings and ask questions, such as:
Are the terms equal?
Is the first term greater than the second?
Is the first term less than the second?
For example, if A = 4 and B = 3, then the results of the previous comparison
questions are:
(A = B) Does 4 = 3?
(A > B) Is 4 > 3?
(A < B) Is 4 < 3?
The more commonly used comparison operators are as follows:
Operator
Meaning
==
Strictly Equal
=
Equal
\ ==
Not strictly equal
\ =
Not equal
>
Greater than
<
Less than
> <
Greater than or less than (same as not equal)
> =
Greater than or equal to
\ <
Not less than
< =
Less than or equal to
\ >
Not greater than
Note: The not character, "¬", is synonymous with the backslash ("\"). The two
characters may be used interchangeably according to availability and
personal preference. This book uses the backslash ("\") character.

The Strictly Equal and Equal Operators

When two expressions are strictly equal, everything including the blanks and case
(when the expressions are characters) is exactly the same.
When two expressions are equal, they are resolved to be the same. The following
expressions are all true.
'WORD' = word
'word ' \== word
'word' == 'word'
4e2 \== 400
4e2 \= 100

Using Comparison Expressions

Often a comparison expression is used in IF/THEN/ELSE instructions. The following
example uses an IF/THEN/ELSE instruction to compare two values. For more
information about this instruction, see "IF/THEN/ELSE Instructions" on page 42.
(A = B)
(A > B)
(A < B)
0 (False)
1 (True)
0 (False)
/* returns 1 */
/* returns 1 */
/* returns 1 */
/* returns 1 */
/* returns 1 */
Chapter 3. Using Variables and Expressions
Using Expressions
31

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents