NUMVAL

The NUMVAL function returns the numeric value represented by the alphanumeric character string specified in an argument. The function strips away any leading or trailing blanks in the string, producing a numeric value that can be used in an arithmetic expression.

The function type is numeric.

Read syntax diagramSkip visual syntax diagram
Format

>>-FUNCTION NUMVAL--(--argument-1--)---------------------------><

argument-1
Must be a nonnumeric literal or an alphanumeric data item whose content has the following formats:
Read syntax diagramSkip visual syntax diagram
>>-+-------+--+----+--+-------+--+-digit--+--------------+-+---->
   '-space-'  +-+--+  '-space-'  |        '-.--+-------+-' |   
              '- --'             |             '-digit-'   |   
                                 '-.--digit----------------'   

>--+-------+---------------------------------------------------><
   '-space-'   

Read syntax diagramSkip visual syntax diagram
>>-+-------+--+-digit--+--------------+-+--+-------+--+----+---->
   '-space-'  |        '-.--+-------+-' |  '-space-'  +-+--+   
              |             '-digit-'   |             +- --+   
              '-.--digit----------------'             +-CR-+   
                                                      '-DB-'   

>--+-------+---------------------------------------------------><
   '-space-'   

space
A string of one or more spaces.
digit
A string of one or more digits. The total number of digits must not exceed 18.

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

The returned value is a floating-point approximation of the numeric value represented by argument-1. See "Conversions and Precision" in the IBM Rational Development Studio for i: ILE COBOL Programmer's Guide for more information.

Related Information