The comparison operators (<, <=, >, >=) work for numbers, strings, and matrices. For matrices, they produce a matrix of results. If you compare mixed arguments, such as strings with numbers or matrices, the result is a missing value. Comparisons involving lists are not allowed and also return missing values.
The equality operators (== and !=) work for numbers, strings, matrices, and lists. For matrices, they produce a matrix of results; for lists, they produce a single result. If you test equality of mixed results (for example. strings with numbers or matrices) the result is 0 or unequal.
a = 1;
Show( 1 <= a < 3 );
b = 2;
Show( 2 < b <= 3 );
1 <= a < 3 = 1;
2 < b <= 3 = 0;
All the comparison operators are eliding operators. That means JMP treats arguments joined by comparison operators as one big clause, as opposed to the way most expressions are evaluated one operator at a time. Evaluating as a single clause produces different results than the more usual method of evaluating in pieces. For example, the following two statements are different:
12 < a < 13;
(12 < a) < 13;
The first statement checks whether a is between 12 and 13, because all three arguments and both operators are read and evaluated together. The second statement uses parentheses to regroup the operations explicitly to evaluate from left to right, which would be the normal way to evaluate most expressions. Thus it first checks whether 12 is less than a, returning 1 if true or 0 if false. Then it checks whether the result is less than 13, which is always true because 0 and 1 are both less than 13.
All the comparison operators are elided when they are used in matched pairs or in the unmatched pairs <... <= and <=... <. What this means is that if you want a comparison statement to be evaluated one comparison operator at a time, you should use parentheses ( ) to control the order of operations explicitly.
1 (true) if a evaluates strictly greater than b (and b evaluates strictly greater than c, and so on).
Greater, Less, GreaterOrEqual, and LessOrEqual can also be strung together. If you do not group with parentheses, JMP evaluates each pair left to right. You can also use parentheses to explicitly tell JMP how to evaluate the expression.
1 (true) if a evaluates strictly greater than or equal to b (and b evaluates strictly greater than or equal to c, and so on).
Greater, Less, GreaterOrEqual, and LessOrEqual can also be strung together. If you do not group with parentheses, JMP evaluates each pair left to right. You can also use parentheses to explicitly tell JMP how to evaluate the expression.
Greater, Less, GreaterOrEqual, and LessOrEqual can also be strung together. If you do not group with parentheses, JMP evaluates each pair left to right. You can also use parentheses to explicitly tell JMP how to evaluate the expression.
1 (true) if a evaluates strictly less than or equal to b (and b evaluates strictly less than or equal to c, and so on).
Greater, Less, GreaterOrEqual, and LessOrEqual can also be strung together. If you do not group with parentheses, JMP evaluates each pair left to right. You can also use parentheses to explicitly tell JMP how to evaluate the expression.
a, b