public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval inumberVE) {ValueEval veText1;try {veText1 = OperandResolver.getSingleValue(inumberVE, srcRowIndex, srcColumnIndex);} catch (EvaluationException e) {return e.getErrorEval();}String iNumber = OperandResolver.coerceValueToString(veText1);Matcher m = Imaginary.COMPLEX_NUMBER_PATTERN.matcher(iNumber);boolean result = m.matches();String real = "";if (result) {String realGroup = m.group(2);boolean hasRealPart = realGroup.length() != 0;if (realGroup.length() == 0) {return new StringEval(String.valueOf(0));}if (hasRealPart) {String sign = "";String realSign = m.group(Imaginary.GROUP1_REAL_SIGN);if (realSign.length() != 0 && !(realSign.equals("+"))) {sign = realSign;}String groupRealNumber = m.group(Imaginary.GROUP2_IMAGINARY_INTEGER_OR_DOUBLE);if (groupRealNumber.length() != 0) {real = sign + groupRealNumber;} else {real = sign + "1";}}} else {return ErrorEval.NUM_ERROR;}return new StringEval(real);}
public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval inumberVE){ValueEval veText1;try{veText1 = OperandResolver.GetSingleValue(inumberVE, srcRowIndex, srcColumnIndex);}catch (EvaluationException e){return e.GetErrorEval();}String iNumber = OperandResolver.CoerceValueToString(veText1);System.Text.RegularExpressions.Match m = Imaginary.COMPLEX_NUMBER_PATTERN.Match(iNumber);bool result = m.Success && !string.IsNullOrEmpty(m.Groups[0].Value);String real = "";if (result == true){String realGroup = m.Groups[(2)].Value;bool hasRealPart = realGroup.Length != 0;if (realGroup.Length == 0){return new StringEval(Convert.ToString(0));}if (hasRealPart){String sign = "";String realSign = m.Groups[(Imaginary.GROUP1_REAL_SIGN)].Value;if (realSign.Length != 0 && !(realSign.Equals("+"))){sign = realSign;}String groupRealNumber = m.Groups[(Imaginary.GROUP2_IMAGINARY_INTEGER_OR_DOUBLE)].Value;if (groupRealNumber.Length != 0){real = sign + groupRealNumber;}else{real = sign + "1";}}}else{return ErrorEval.NUM_ERROR;}return new StringEval(real);}