StringIsFloat

首页  后退  前进

StringIsFloat
down2

StringIsFloat

检查字符串是否为浮点数.

 

StringIsFloat ( "string" )

参数

string

目标字符串.

返回值

成功:

返回 1.

失败:

返回 0, 并非浮点数格式.

备注

如果字符串含有至少一个十进制数和小数点, 则为浮点数; 其它开头的字符允许为加号或减号.

(本函数不接受逗号作为小数点; 即使是电脑的区域设置中已设置使用该符号也不接受.)

如果参数不是字符串, 其值应转换为字符串. 见示例.

 

函数示例

#include <MsgBoxConstants.au3>
MsgBox($MB_SYSTEMMODAL, "", "Is the string 1.5 a floating point number: " & StringIsFloat("1.5") & @CRLF & _ ; Returns 1, due to the decimal point.
        "Is the string 7. a floating point number: " & StringIsFloat("7.") & @CRLF & _ ; Returns 1, due to the decimal point.
        "Is the string 3/4 a floating point number: " & StringIsFloat("3/4") & @CRLF & _ ; Returns 0, as the string 3 / (forward slash) 4 is not a floating point number.
        "Is the number 1.0 a floating point number: " & StringIsFloat(1.0) & @CRLF & _ ; Returns 1, due to the number to string conversion as well as the decimal point.
        "Is the string 2 a floating point number: " & StringIsFloat("2") & @CRLF) ; Returns 0, due to 2 being an integer.

----------------------------------------

 

该函数可以通过命令 exect 调用

参见:

StringIsInt, IsFloat, StringIsDigit

例子
copy
StringIsFloat('1.5') ;; 返回1

StringIsFloat('7.') ;; 返回1,因为它包含一个小数点

StringIsFloat('-.0') ;; 返回1

StringIsFloat('3/4') ;; 返回0,因为'3'斜杠'4'不是带有句点的数字

StringIsFloat('2') ;; возвращает 0 поскольку '2' целое число, не число с точкой

 

;; 数字数据转换为小写,因此结果不同

StringIsFloat(1.5) ;; 返回1,因为1.5转换为字符串包含一个点

StringIsFloat(1.0) ;; 返回0,因为1.0转换为字符串不包含句点

StringIsFloat(1.5e3) ;; 返回0,因为1.5e3 = 1500

StringIsFloat(3/4) ;; 返回1,因为除法的结果包含一个句点。

 

exect=$var_is=StringIsFloat('1.5')||$var_bb=StringIsFloat('2') GLOBALEXECT<a> ;; 检查浮点数是否为

up2

tcimage © Аверин Андрей для Total Commander Image Averin-And@yandex.ru