lz_gmean
The geometric mean of a list.
long lz_gmean( CLZNumber** values, long count, CLZNumber* targetNumber );
The nth root of the product of n values, correctly rounded. It takes an array and a count, as lz_amean does, and the target is required. A negative value is refused, kFailed, flagged not-a-number, and a nought makes the mean nought.
Examples
| Call | Answer | Returns |
|---|---|---|
lz_gmean( { 2, 8 } ) | 4 | kNoError |
lz_gmean( { 1, 2, 3, 4 } ) | 2.213363839400643184817580546880663297 | kNoError |
lz_gmean( { 0, 5 } ) | 0 | kNoError |
lz_gmean( { −1, 4 } ) | not a number | kFailed |
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.