# EPIC

### EPIC News

isnumber

# \$EPIC: isnumber.txt,v 1.2 2006/08/01 03:40:36 sthalik Exp \$

# Synopsis:

\$isnumber(<text>)
\$isnumber(b<base-num> <text>)
\$isnumber(<text> b<base-num>)

# Technical:

• The <base-num> argument may either be the first or second word, but in either case must be prefixed with the literal 'b' character.
• The <text> argument may either be the first or second word, but in either case must NOT be prefixed with the literal 'b' character.
• If the <base-num> argument is not specified, the default value is 0.
• If <base-num> is 0, the number base is auto-detected.
• <text> is taken to be a string containing an integer value, a decimal point ('.' – sorry), and another integer value; comprised of digits which are legal in the indicated base.
• If a decimal point is used and the <base-num> is 0, then the integer value after the decimal point must be in base 10 and will not be auto-detected.
• The return value is 1 if <text> is a valid number in the indicated base, and 0 if <text> is not a valid number in the indicated base.

# Practical:

Wow. That's complicated. This function (believe it or not) just tells you whether or not <text> is a number. You can specify a number base (such as b8, or b16) to see if <text> is a number in a base other than base 10. This is neccesary if you want to octal or hexidecmial numbers for validity.

# Returns:

1 if <text> is a valid number of base <base-num>; 0 if not.

# Examples:

```\$isnumber(10)             returns 1
\$isnumber(hello)          returns 0
\$isnumber(0xdeadbeef)     returns 1  (all hex digits!)
\$isnumber(b8 0xdeadbeef)  returns 0  (not an octal number!)
\$isnumber(b8 07f932)      returns 0  (9 is not an octal digit!)
\$isnumber(3.4)            returns 1
\$isnumber(b16 a.f)        returns 1
\$isnumber(a.f)            returns 0  (hex digits invalid without 0x)
\$isnumber(0xa.0)          returns 1
\$isnumber(b16 a.f)        returns 1  (hex digits valid with b16)```