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 < 1.0){return ErrorEval.NUM_ERROR;}int k = (int)Math.Ceiling(dn);double result;try{double[] ds = NPOI.SS.Formula.Functions.AggregateFunction.ValueCollector.CollectValues(arg0);if (k > ds.Length){return ErrorEval.NUM_ERROR;}result = _isLarge ? StatsLib.kthLargest(ds, k) : StatsLib.kthSmallest(ds, k);NumericFunction.CheckValue(result);}catch (EvaluationException e){return e.GetErrorEval();}return new NumberEval(result);}