lz_amean
The arithmetic mean of a list.
long lz_amean( CLZNumber** values, long count, CLZNumber* targetNumber );
The sum of the values over their count, rounded once. It takes an array of pointers and a count, and the target is required, kFailed if null:
CLZNumber* values[] = { &a, &b, &c };
lz_amean( values, 3, &result );
The values are never modified, so the target may be one of them. An infinity or a not-a-number among them makes the answer a not-a-number. Values in different bases are worked exactly, and the answer is in the first value's base.
Examples
| Call | Answer |
|---|---|
lz_amean( { 1, 2, 3, 4 } ) | 2.5 |
lz_amean( { 0.1, 0.2, 0.3 } ) | 0.2 |
lz_amean( { 1, 2 } ) | 1.5 |
Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.
Returns
kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.