text: public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0,ValueEval arg1){double dn;try{ValueEval ve1 = OperandResolver.GetSingleValue(arg1, srcRowIndex, srcColumnIndex);dn = OperandResolver.CoerceValueToDouble(ve1);}catch (EvaluationException){return ErrorEval.VALUE_INVALID;}if (dn < 0 || dn > 1){ return ErrorEval.NUM_ERROR;}double result;try{double[] ds = NPOI.SS.Formula.Functions.AggregateFunction.ValueCollector.CollectValues(arg0);int N = ds.Length;if (N == 0 || N > 8191){return ErrorEval.NUM_ERROR;}double n = (N - 1) * dn + 1;if (n == 1d){result = StatsLib.kthSmallest(ds, 1);}else if (n == N){result = StatsLib.kthLargest(ds, 1);}else{int k = (int)n;double d = n - k;result = StatsLib.kthSmallest(ds, k) + d* (StatsLib.kthSmallest(ds, k + 1) - StatsLib.kthSmallest(ds, k));}NumericFunction.CheckValue(result);}catch (EvaluationException e){return e.GetErrorEval();}return new NumberEval(result);}