This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
2018numeric_cmp [2018/09/07 14:01] david [Importance of Testing] |
2018numeric_cmp [2018/09/07 14:01] david [Correct Numeric Comparisons] |
||
---|---|---|---|
Line 11: | Line 11: | ||
You must use the flag operators, or the symbolic operators inside double parentheses, to correctly compare values numerically. | You must use the flag operators, or the symbolic operators inside double parentheses, to correctly compare values numerically. | ||
For example, say ''a=2'' and ''b=10'': | For example, say ''a=2'' and ''b=10'': | ||
- | * <nowiki>[ $a -lt $b ]</nowiki> is TRUE | + | * <nowiki>[ 2 -lt 10 ]</nowiki> is TRUE |
- | * <nowiki>[[ $a -lt $b ]]</nowiki> is TRUE | + | * <nowiki>[[ 2 -lt 10 ]]</nowiki> is TRUE |
- | * <nowiki>[[ $a -ge $b ]]</nowiki> is FALSE | + | * <nowiki>[[ 2 -ge 10 ]]</nowiki> is FALSE |
- | * <nowiki>(( $a < $b ))</nowiki> is TRUE | + | * <nowiki>(( 2 < 10 ))</nowiki> is TRUE |
===== Incorrect Numeric Comparisons (lexicographic order) ===== | ===== Incorrect Numeric Comparisons (lexicographic order) ===== |