HP3000 Manuals

NUMVAL Function [ HP COBOL II/XL Reference Manual ]

HP COBOL II/XL Reference Manual

NUMVAL Function 

The NUMVAL function returns the numeric value represented by the
character string specified by parameter-1.  Leading and trailing spaces
are ignored.  The function type is numeric.

Syntax 

     FUNCTION NUMVAL (parameter-1)

Parameters 

parameter-1           Must be a nonumeric literal or alphanumeric data
                      item whose content has one of the following
                      formats:

	       Click here to view figure.
            

                      where space is a string of zero or more spaces and
                      digits is a string of one to eighteen digits.  The
                      total number of digits in parameter-1 must not
                      exceed 18.

                      If the DECIMAL-POINT IS COMMA clause is specified
                      in the SPECIAL-NAMES paragraph, a comma must be
                      used in parameter-1 rather than a decimal point.

Return Value 

The returned value is the numeric value represented by parameter-1.

Example 

     77  ALPHA-NUM     PIC XXX VALUE "753".
     77  NUM           PIC 999 VALUE ZERO.
           :
     COMPUTE NUM = FUNCTION NUMVAL (ALPHA-NUM).
     DISPLAY ALPHA-NUM.
     DISPLAY NUM.

The above example displays the following:

     753
     753