Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

SUM - Sum of arguments

The SUM function returns a value that is the sum of all the arguments.

The type of this function depends upon the argument types as follows:

Argument type

Function type

all arguments integer
all arguments numeric
mix of integer/numeric

integer
numeric
numeric

Format


FUNCTION SUM ({argument-1}...)


Argument

  1. argument-1 must be class "numeric".

Returned values

  1. The returned value is the sum of all the arguments.

  2. The error default value is 0.


See also:
        MAX, MIN, RANGE, MEAN, MEDIAN, MIDRANGE

Example 9-44

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  RES PIC 9(3).
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    COMPUTE RES = FUNCTION SUM (12 32 5 8 17 9).
    DISPLAY RES UPON T.
    STOP RUN.

Result:              00000083