is numeric / integer - Functions

Prev Next

Function Names

is numeric, is integer, is numeric or blank, is integer or blank, is strictly numeric, is strictly integer, is strictly numeric or blank, is strictly integer or blank

Description

is numeric returns true if the value provided is a numeral
is numeric or blank returns true if the value provided is a numeral or a blank string.
is integer returns true if the value provided is a whole number (aka integer)
is integer or blank returns true if the value provided is a whole number (aka integer) or a blank string.
is strictly numeric returns true if the value provided is a numeral
is strictly numeric or blank returns true if the value provided is a numeral or a blank string.
is strictly integer returns true if the value provided is a whole number (aka integer)
is striclty integer or blank returns true if the value provided is a whole number (aka integer) or a blank string.


Attention: If the function name does not contain the word strictly, then strings containing legitimate numbers with and without decimal point, minus sign and scientific notation (exponents) are also considered as numbers.

Vectorization: These functions support vectorization in the 1st function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1

Parameters

No.TypeDescription
1
input
valid types Value

Value to check. Vectorization is used if a set is provided.

Return value

TypeDescription
boolean
set
Result

true if criteria is met. Multiple values are returned in a set if vectorization has been made use of.

Examples

               a[] = { 1, '1', 1.1, '1.1', '1.1E+03', '1.1234E+03', '', ' ', 'a' };
           for all( a[], p[] )
               {
                       print(p[],": is ");
                       if (is numeric(p[])) print ("numeric, ");
                       if (is strictly numeric(p[])) print ("strictly numeric, ");
                       if (is integer(p[])) print ("integer, ");
                       if (is strictly integer(p[])) print ("strictly integer, ");
                       if (is numeric or blank(p[])) print ("numeric or blank, ");
                       if (is strictly numeric or blank(p[])) print ("strictly numeric or blank, ");
                       if (is integer or blank(p[])) print ("integer or blank, ");
                       if (is strictly integer or blank(p[])) print ("strictly integer or blank, ");
                       echo;
                       echo("Vectorization: ", is numeric(a[]) );
               }

Output

1: is numeric, strictly numeric, integer, strictly integer, numeric or blank, strictly numeric or blank, integer or blank, strictly integer or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
1: is numeric, integer, numeric or blank, integer or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
1.1: is numeric, strictly numeric, numeric or blank, strictly numeric or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
1.1: is numeric, numeric or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
1.1E+03: is numeric, integer, numeric or blank, integer or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
1.1234E+03: is numeric, numeric or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
: is numeric or blank, strictly numeric or blank, integer or blank, strictly integer or blank,
Vectorization: {true,true,true,true,true,true,false,false,false}
: is
Vectorization: {true,true,true,true,true,true,false,false,false}
a: is
Vectorization: {true,true,true,true,true,true,false,false,false}
Try it yourself: Open LIB_Function_is_numeric.b4p in B4P_Examples.zip. Decompress before use.

See also

whole
describe