ILE COBOL Language Reference


NUMVAL-C

The NUMVAL-C function returns the numeric value represented by the alphanumeric character string specified as argument-1. Any optional currency sign specified by argument-2 and any optional commas preceding the decimal point are stripped away, producing a numeric value that can be used in an arithmetic expression.

The NUMVAL-C function may not be specified under the following conditions:

The function type is numeric.

Format
 
>>-FUNCTION NUMVAL-C--(--argument-1-+------------+--)----------><
                                    '-argument-2-'
 
 
argument-1
Must be a nonnumeric literal or an alphanumeric data item whose content has the following formats:
>>-+-------+--+----+--+-------+--+----+--+-------+-------------->
   '-space-'  +-+--+  '-space-'  '-cs-'  '-space-'
              '- --'
 
>--+-digit--+--------------+--+--------------+-+--+-------+----><
   |        | .----------. |  '-.--+-------+-' |  '-space-'
   |        | V          | |       '-digit-'   |
   |        '---,--digit-+-'                   |
   '-.--digit----------------------------------'
 
 
>>-+-------+--+----+--+-------+--------------------------------->
   '-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 specified by argument-2. At most, one copy of the characters specified by cs can occur in argument-1.
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, the functions of the comma and decimal point in argument-1 are reversed.

argument-2
If specified, must be a nonnumeric literal or alphanumeric data item, subject to the following rules:

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

The returned value is an approximation of the numeric value represented by argument-1.

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]