[AIT logo]

Institut für Astronomie und Astrophysik

Abteilung Astronomie

Sand 1, D-72076 Tübingen, Germany
[Uni logo]


STRNUMBER() Source code in strnumber.pro

STRNUMBER()

Name
      STRNUMBER()
Purpose
      Function to determine if a string is a valid numeric value.
Explanation
      A string is considered a valid numeric value if IDL can convert it
      to a numeric variable without error.
Calling Sequence
      result = strnumber( st, [val, /HEX] )
Input Parameters
      st - any IDL scalar string
Output Parameters
      1 is returned as the function value if the string st has a
      valid numeric value, otherwise, 0 is returned.
Optional Output
      val - (optional) value of the string.  real*8
Keyword Parameters
       /HEX - If present and nonzero, the string is treated as a hexadecimal
             longword integer.
       /NAN - if set, then the value of an empty string is returned as NaN,
              by default the returned value is 0.0d.     In either case,
              an empty string is considered a valid numeric value.
Example
      IDL> res = strnumber('0.2d', val)
           returns res=1 (a valid number), and val = 0.2000d
Note
      (1) STRNUMBER was modified in August 2006 so that an empty string is
      considered a valid number.   Earlier versions of strnumber.pro did not
      do this because in very early (pre-V4.0) versions of IDL
      this could corrupt the IDL session.
       (2) STRNUMBER will return a string such as '23.45uyrg' as a valid
      number (=23.45) since this is how IDL performs the type conversion.  If
      you want a stricter definition of valid number then use the VALID_NUM
      function.
Revision History
      version 1  By D. Lindler Aug. 1987
      test for empty string, W. Landsman          February, 1993
      Converted to IDL V5.0   W. Landsman   September 1997
      Hex keyword added.  MRG, RITSS, 15 March 2000.
      An empty string is a valid number   W. Landsman    August 2006
      Added /NAN keyword  W. Landsman August 2006

Last modified by pro2html on 2006 December 20 at 04:12 UTC

[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]

Jörn Wilms (wilms@astro.uni-tuebingen.de)
Updated automatically