下面这个脚本判断用户的输入是否是正整数,输入 小数,负数,字母都能检测出,但是如果提示完 "Positive parameter only,please input:",直接敲入回车,就打印出 [ : -lt : unary operator expected, 令:我怎么在shell中输入小数进行算术啊,好像expr只处理整数 #!../../../bin/sh para=a while : do expr $para + 3 > ../../../dev/null 2>&1 if [ $? -ne 0 ] || [ $para -lt 1 ] ; then echo -n "Po...
by virusolf - Shell - 2008-07-15 22:15:28 阅读(4432) 回复(22)
位操作的运用: [code]bool Is2Power(int nNum) { return nNum > 0 ? ((nNum & (~nNum + 1)) == nNum ? true : false) : false; }[/code] [ 本帖最后由 converse 于 2006-7-11 00:18 编辑 ]
java中判断字符串是否为数字的方法: 1.用JAVA自带的函数 public static boolean isNumeric(String str){ for (int i = 0; i http://jakarta.apache.org/commons/lang/api-release/index.html 下面的解释: isNumeric public static boolean isNumeric(String str)Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false. null will return false. An empty String ("")...