Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Language Reference


NUMVAL

The NUMVAL function returns the numeric value represented by the alphanumeric character string or national character string specified as the argument. The function removes any leading or trailing spaces in the string to produce a numeric value.

The function type is numeric.

Read syntax diagramSkip visual syntax diagram
Format

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

argument-1
Must be an alphanumeric literal, a national literal, or a data item of class national or class alphanumeric that contains a character string in either of the following formats:
Read syntax diagramSkip visual syntax diagram
Format 1: argument-1

>>-+-------+--+----+--+-------+--+-digit--+--------------+-+---->
   '-space-'  +-+--+  '-space-'  |        '-.--+-------+-' |   
              '- --'             |             '-digit-'   |   
                                 '-.--digit----------------'   

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

Read syntax diagramSkip visual syntax diagram
Format 2: argument-1, monetary format

>>-+-------+--+-digit--+--------------+-+--+-------+--+----+---->
   '-space-'  |        '-.--+-------+-' |  '-space-'  +-+--+   
              |             '-digit-'   |             +- --+   
              '-.--digit----------------'             +-CR-+   
                                                      '-DB-'   

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

space
A string of one or more spaces.
digit
A string of one or more digits. If the ARITH(COMPAT) compiler option is in effect, the total number of digits must not exceed 18. If the ARITH(EXTEND) compiler option is in effect, the total number of digits must not exceed 31.

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. The precision of the returned value depends on the setting of the ARITH compiler option. For details, see Converting to numbers (NUMVAL, NUMVAL-C) in the Enterprise COBOL Programming Guide


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)