Difference between revisions of "Average"
From SCAR Divi Manual
Line 1: | Line 1: | ||
==Definition== | ==Definition== | ||
<source lang="scar" lines="false"> | <source lang="scar" lines="false"> | ||
− | function Average(Values: | + | function Average(const Values: TExtArray): Extended; |
</source> | </source> | ||
===Source Code=== | ===Source Code=== | ||
<source lang="scar"> | <source lang="scar"> | ||
− | function Average(Values: | + | function Average(const Values: TExtArray): Extended; |
var | var | ||
i, l: Integer; | i, l: Integer; | ||
Line 21: | Line 21: | ||
==Availability== | ==Availability== | ||
SCAR Divi 3.20 > Current | SCAR Divi 3.20 > Current | ||
+ | |||
+ | *Before 3.34 the '''Values''' parameter used the type [[TExtendedArray]]. | ||
==Description== | ==Description== |
Revision as of 16:58, 23 April 2012
Definition
function Average(const Values: TExtArray): Extended;
Source Code
function Average(const Values: TExtArray): Extended; var i, l: Integer; begin Result := 0; l := Length(Values); if l = 0 then Exit; for i := 0 to l - 1 do Result := Result + Values[i]; Result := Result / l; end;
Availability
SCAR Divi 3.20 > Current
- Before 3.34 the Values parameter used the type TExtendedArray.
Description
Calculates the arithmetic mean of a given set of extended floating point values specified by the TExtendedArray Values.
Example
var Values: array of Extended; begin Values := [1.2, 1.9, 2.9, 5.55, 8.69]; WriteLn(Average(Values)); end.
Output:
4,048