DelphiBasics
Sum
Function
Return the sum of an array of floating point values Math unit
 function Sum ( const Numbers : array of Double ) : Double;
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
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.


 
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;

  ShowMessage('Sum of array values = '+FloatToStr(Sum(doubles)));
  ShowMessage('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
 
Delphi Programming Neil Moffatt 2002 - 2016. All rights reserved.  |  Home Page