A relational expression evaluates to 1 if the relation is true, and evaluates to 0 if the relation is false. Relational operators have lower precedence than all arithmetic and string operators. Therefore, relational operators are only evaluated after all arithmetic and string operations have been evaluated.
If one operand is numeric and one operand is string, both operands are treated as strings. To resolve a numeric relation, the values of the expression are compared. To resolve a string relation, the characters in each string are compared one at a time from leftmost characters to right-most. If no unequal character pairs are found, the strings are considered to be equal.
If the two strings are not the same length, and the shorter string is otherwise identical to the beginning of the longer string, the longer string is considered greater than the shorter string.
The resolution of unequal character pairs depends on the characters. If the unequal pair of characters are nonalphabetical characters, the characters are ranked according to their numeric ASCII code equivalents. The string contributing the higher numeric ASCII code equivalent is considered to be greater than the other string. If the unequal pair of characters are alphabetical, the pair is ranked in strict alphabetical order.
If one of the characters is alphabetical and the other character is nonalphabetical, the characters are ranked according to the numeric ASCII value of the uppercase letter, even if the letter is in lowercase, and the numeric ASCII value of the nonalphabetical character.