addaptic

Reference Means

lz_hmean

The harmonic mean of a list.

long lz_hmean( CLZNumber** values, long count, CLZNumber* targetNumber );

The count over the sum of the reciprocals, 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

CallAnswer
lz_hmean( { 1, 2, 4 } )1.714285714285714285714285714285714286
lz_hmean( { 40, 60 } )48
lz_hmean( { 0, 5 } )0

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.

See also