Class: String
Description
This method indicates whether the string is a number.
A String represents a number if one of the following conditions is satisfied:
The string consists of zero or more digits followed by a decimal dot followed by one or more digits. Leading and trailing zeros are not acceptable.
In formal terms, STR.isNumber() = 1 if and only if (STR.toNumber()).toString()=STR.
Syntax
StringObject.isNumber()
Parameters
None. |
|
Returns
A Boolean:
1, if the string represents a number.
0, if the string does not represent a number.
When Became Available
v6.4
Example
// see Examples of String.isInteger for other cases that
// return 0.
// String.isInteger() implies String.isNumber()
type String NUM = "123"
type Boolean B = NUM.isNumber() // 1
// leading and trailing zeros are not OK
set NUM = "012"
set B = NUM.isNumber() // 0
set NUM = "12.50"
set B = NUM.isNumber() // 0
set NUM = "0.123" // even "fraction only" shall
set B = NUM.isNumber() // have no leading zero: 0
set NUM = ".123" // A canonical fraction shall
set B = NUM.isNumber() // start with dot: 1
// single leading minus is OK
set NUM = "-123.456"
set B = NUM.isNumber() // 1
// plus sign is not allowed
set NUM = "+123.456"
set B = NUM.isNumber() // 0