Description |
The Sum function returns the sum of the values in the supplied Numbers array of double values.
|
|
Related commands |
Dec |
|
Decrement an ordinal variable |
Inc |
|
Increment an ordinal variable |
Sqr |
|
Gives the square of a number |
Sqrt |
|
Gives the square root of a number |
|
|
|
Example code : Examples of summing arrays and hard coded values |
var
doubles : array[0..5] of double;
begin // Fill up the number array
doubles[0] := 25.0;
doubles[1] := 100.5;
doubles[2] := -4.125;
doubles[3] := 75.0;
doubles[4] := -62.0;
doubles[5] := 0.0;
WriteLn('Sum of array values = '+FloatToStr(Sum(doubles)));
WriteLn('12.3 + 45.6 = '+FloatToStr(Sum([12.3, 45.6])));
end;
|
Show full unit code |
Sum of array values = 134.375
12.3 + 45.6 = 57.9
|
|