Product SiteDocumentation Site

1.11.2.3. Comparison

The comparison operators compare two terms and return the value 1 if the result of the comparison is true, or 0 otherwise.
The strict comparison operators all have one of the characters defining the operator doubled. The ==, \==, and ¬== operators test for an exact match between two strings. The two strings must be identical (character by character) and of the same length to be considered strictly equal. Similarly, the strict comparison operators such as >> or << carry out a simple character-by-character comparison, with no padding of either of the strings being compared. The comparison of the two strings is from left to right. If one string is shorter than the other and is a leading substring of another, then it is smaller than (less than) the other. The strict comparison operators also do not attempt to perform a numeric comparison on the two operands.
For all other comparison operators, if both terms involved are numeric, a numeric comparison (see Section 10.4, “Numeric Comparisons”) is effected. Otherwise, both terms are treated as character strings, leading and trailing whitespace characters are ignored, and the shorter string is padded with blanks on the right.
Character comparison and strict comparison operations are both case-sensitive, and the exact collating order might depend on the character set used for the implementation. In an ASCII environment, such as Windows and *nix, the ASCII character value of digits is lower than that of the alphabetic characters, and that of lowercase alphabetic characters is higher than that of uppercase alphabetic characters.
The comparison operators and operations are:
=
True if the terms are equal (numerically or when padded)
\=, ¬=
True if the terms are not equal (inverse of =)
>
Greater than
<
Less than
><
Greater than or less than (same as not equal)
<>
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
==
True if terms are strictly equal (identical)
\==, ¬==
True if the terms are not strictly equal (inverse of ==)
>>
Strictly greater than
<<
Strictly less than
>>=
Strictly greater than or equal to
\<<, ¬<<
Strictly not less than
<<=
Strictly less than or equal to
\>>, ¬>>
Strictly not greater than

Note

Throughout the language, the NOT (¬) character is synonymous with the backslash(\). You can use the two characters interchangeably, according to availability and personal preference. The backslash can appear in the following operators: \ (prefix not),\=, \==, \<, \>, \<<, and \>>.