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 1: argument-1 >>-+-------+--+-----+--+-------+--+----+--+-------+-------------> '-space-' +- + -+ '-space-' '-cs-' '-space-' '- - -' >--+-digit--+--------------+--+--------------+-+--+-------+---->< | | .----------. | '-.--+-------+-' | '-space-' | | V | | '-digit-' | | '---,--digit-+-' | '-.--digit----------------------------------'
Format 2: argument-1, monetary format >>-+-------+--+----+--+-------+---------------------------------> '-space-' '-cs-' '-space-' >--+-digit--+--------------+--+--------------+-+--+-------+-----> | | .----------. | '-.--+-------+-' | '-space-' | | V | | '-digit-' | | '---,--digit-+-' | '-.--digit----------------------------------' >--+-----+--+-------+------------------------------------------>< +- + -+ '-space-' +- - -+ +-CR--+ '-DB--'
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.
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 number (NUMVAL, NUMVAL-C) in the COBOL for AIX Programming Guide.