Rational Developer for System z
COBOL for Windows, Version 7.5, Language Reference


NUMVAL-C

The NUMVAL-C function returns the numeric value represented by the alphanumeric character string or national character string specified as argument-1. The function removes the currency string, if any, and any grouping separators (commas or periods) to produce a numeric value.

The function type is numeric.

Format
Read syntax diagramSkip visual syntax diagram>>-FUNCTION NUMVAL-C--(--argument-1--+------------+--)---------><
                                     '-argument-2-'     
 
argument-1
Must be an alphanumeric literal, a national literal, or a data item of class alphanumeric or class national that contains a character string in either of the following formats:

Format 1: argument-1
Read syntax diagramSkip visual syntax diagram>>-+-------+--+-----+--+-------+--+----+--+-------+------------->
   '-space-'  +- + -+  '-space-'  '-cs-'  '-space-'  
              '- - -'                                
 
>--+-digit--+--------------+--+--------------+-+--+-------+----><
   |        | .----------. |  '-.--+-------+-' |  '-space-'  
   |        | V          | |       '-digit-'   |             
   |        '---,--digit-+-'                   |             
   '-.--digit----------------------------------'             
 

Format 2: argument-1
Read syntax diagramSkip visual syntax diagram>>-+-------+--+----+--+-------+--------------------------------->
   '-space-'  '-cs-'  '-space-'  
 
>--+-digit--+--------------+--+--------------+-+--+-------+----->
   |        | .----------. |  '-.--+-------+-' |  '-space-'  
   |        | V          | |       '-digit-'   |             
   |        '---,--digit-+-'                   |             
   '-.--digit----------------------------------'             
 
>--+-----+--+-------+------------------------------------------><
   +- + -+  '-space-'  
   +- - -+             
   +-CR--+             
   '-DB--'             
 
space
A string of one or more spaces.
cs
The string of one or more characters that form the currency sign. At most one copy of the characters specified by cs can occur in argument-1.
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, the functions of the comma and decimal point in argument-1 are reversed.

 
argument-2
Specifies the currency string value.

The following rules apply:

If argument-2 is not specified, the character used for cs is the currency symbol specified for the program.

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 COBOL for Windows Programming Guide


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)