Documentation for pp_lib

Generated by IDLdoc

./

pp_isnumber.pro


top source pp_isnumber

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

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

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:
39 lines
McCabe complexity:
13

File attributes

Modification date: Tue Apr 22 21:53:14 2014
Lines: 86
Docformat: rst rst