Relational Operators

There are six relational operators:

Here are important rules:

Examples

Comparing CHARACTER Strings

Characters are encoded. Different standards (e.g. BCD, EBCDIC and ASCII) may have different encoding schemes. To write a program that can run on all different kind of computers and get the same comparison results, one can only assume the following ordering sequences:
A < B < C < D < E < F < G < H < I < J < K < L < M
  < N < O < P < Q < R < S < T < U < V < W < X < Y < Z

a < b < c < d < e < f < g < h < i < j < k < l < m
  < n < o < p < q < r < s < t < u < v < w < x < y < z

0 < 1 < 2 < 3 < 4 < 5 < 6 < 7 < 8 < 9
If you compare characters in different sequences such as 'A' < 'a' and '2' >= 'N', you are asking for trouble since different encoding methods may produce different answers. Moreover, do not assume there exists a specific order among upper and lower case letters, digits, and special symbols. Thus, '+' <= 'A', '*' >= '%', 'u' > '$', and '8' >= '?' make no sense. However, you can always compare if two characters are equal or not equal. Hence, '*' /= '9', 'a' == 'B' and '8' == 'b' are perfectly fine.

Here is the method for comparing two strings:


Examples

A Special Note

The priority of all six relational operators is lower than the string concatenation operator //. Therefore, if a relational expression involves //, then all string concatenations must be carried out before evaluating the comparison operator. Here is an example:
"abcde" // "xyz" < "abc" // ("dex" // "ijk")
     --> ["abcde" // "xyz"] < "abc" // ("dex" // "ijk")
     --> "abcdexyz" < "abc" // ("dex" // "ijk")
     --> "abcdexyz" < "abc" // (["dex" // "ijk"])
     --> "abcdexyz" < "abc" // ("dexijk")
     --> "abcdexyz" < "abc" // "dexijk"
     --> "abcdexyz" < ["abc" // "dexijk"]
     --> "abcdexyz" < "abcdexijk"
     --> .FALSE.