HP 3000 Manuals

SUM [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

SUM 

The SUM function returns the sum of the elements in a numeric array.  If
the array is a short integer array, the result is an integer; otherwise,
the result is the same type as the array.

Syntax 

SUM(num_array)

Parameters 

num_array        Structured collection of variables of the same numeric
                 type.  The structure is determined when the array is
                 declared.

Examples 

OPTION BASE 1 is assumed.

     A(2,2): 1 2   B(2,4):  1 2 3 4   C(4,3,2): 1 2  0 4   0 0  1 2
             4 5            5 6 7 8             5 1  1 0   4 5  0 0
                                                2 0  3 2   1 2  0 1

     D(3,3): 1 0 1  E(2,2): 8 3       F(5): 5 4 3 2 1
             3 5 7          4 7
             9 0 9

     SUM(A) = 1+2+4+5 = 12
     SUM(B) = 1+2+3+4+5+6+7+8 = 36
     SUM(C) = 1+2+4+5+1+1+2+3+2+1+2+4+5+1+2+1 = 35
     SUM(D) = 1+1+3+5+7+9+9 = 35
     SUM(E) = 8+3+4+7 = 22
     SUM(F) = 5+4+3+2+1 = 15



MPE/iX 5.0 Documentation