User Tools

Site Tools


2018numeric_cmp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
2018numeric_cmp [2018/09/07 14:01]
david [Importance of Testing]
2018numeric_cmp [2018/09/07 14:02]
david [Incorrect Numeric Comparisons (lexicographic order)]
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>​[ ​-lt 10 ]</​nowiki>​ is TRUE 
-  * <​nowiki>​[[ ​$a -lt $b ]]</​nowiki>​ is TRUE +  * <​nowiki>​[[ ​-lt 10 ]]</​nowiki>​ is TRUE 
-  * <​nowiki>​[[ ​$a -ge $b ]]</​nowiki>​ is FALSE +  * <​nowiki>​[[ ​-ge 10 ]]</​nowiki>​ is FALSE 
-  * <​nowiki>​(( ​$a $b ))</​nowiki>​ is TRUE+  * <​nowiki>​(( ​10 ))</​nowiki>​ is TRUE
  
 ===== Incorrect Numeric Comparisons (lexicographic order) ===== ===== Incorrect Numeric Comparisons (lexicographic order) =====
 What results in an alphanumeric comparison (which has unexpected behavior), or a syntax error (which you may overlook) is the following: What results in an alphanumeric comparison (which has unexpected behavior), or a syntax error (which you may overlook) is the following:
-  * <​nowiki>​[[ ​$a $b ]]</​nowiki>,​ alphanumerically FALSE +  * <​nowiki>​[[ ​10 ]]</​nowiki>,​ alphanumerically FALSE 
-  * <​nowiki>​[ ​$a $b ]</​nowiki>,​ error; also FALSE.+  * <​nowiki>​[ ​10 ]</​nowiki>,​ error; also FALSE.
  
 ===== Importance of Testing ===== ===== Importance of Testing =====
2018numeric_cmp.txt · Last modified: 2018/09/07 14:02 by david