Documentation for pp_lib

Generated by IDLdoc

single page | use frames     summary     class     fields     routine details     file attributes

./

pp_isnumber.pro


Routines

top source pp_isnumber

result = pp_isnumber(istr [, nan=nan] [, infinity=infinity] [, trim=trim] [, integer=integer] [, blank=blank] [, all=all])

Tests a string to determine if it can be converted to a floating point number. All tests are case-insensitive. String must be trimmed on both sides: if it contains leading or trailing blanks, it is not considered a number.

Return value

True if str is a floating point number, or (optionally), NaN or Infinity.

False otherwise, including if str is undefined or is blank (unless the keyword blank is set).

Parameters

istr in required

String or string array to test.

Keywords

nan in optional default=1

If set, NaN is allowed as a number.

infinity in optional default=1

If set, Infinity is allowed as a number (any of inf,infi,infin,infini,infinit,infinity).

trim in optional default=1

If set, blanks on the string (on both sides) are ignored (a call is made to strtrim).

integer in optional default=0

If set, will test for integer numbers, instead of real numbers.

blank in optional default=0

If set, blanks are allowed as numbers

all in optional default=0

If set and the input is an array, pp_isnumber will return a single 0 or 1, indicating whether every element in the array passed the test.

Examples

Test some simple cases:

print,pp_isnumber(['a','12','-1','1.8','.9','-.8e-3','NaN','infinity','a12']) ; 0 1 1 1 1 1 1 1 0 ;print,pp_isnumber(['a','12','-1','1.8','.9','-.8e-3','NaN','infinity','a12'],nan=0,infinity=0) ; 0 1 1 1 1 1 0 0 0 print,pp_isnumber(['a','12','-1','1.8','.9','-.8e-3','NaN','infinity','a12'],/integer) ; 0 1 1 0 0 0 0 0 0

Author information

Author:

Paulo Penteado (pp.penteado@gmail.com), Aug/2009

Other attributes

Uses:

Statistics

Lines:
28 lines
Cyclomatic complexity:
11
Modified cyclomatic complexity:
11

File attributes

Modification date: Wed Jun 29 22:15:28 2016
Lines: 28
Docformat: rst rst