/// <summary> /// 参数说明 /// value:修约的数值 /// precision:0表示保留到整数,-1表示保留一位小数,-2标书保留两位小数 /// roundRule:0表示四舍六入五单双,0.2表示0.2修约,0.5表示0.5修约 /// </summary> /// <param name="args"></param> /// <returns></returns> public override object Evaluate(object[] args) { double value = 0; int precision = 1; string roundRule = "0"; double r = 0; try { value = ArgumentConvert.ToDouble(args[0]); precision = ArgumentConvert.ToInt(args[1]); roundRule = ArgumentConvert.ToString(args[2]); switch (roundRule) { case "0": r = numericalRound.Evaluate(value, precision); break; case "0.2": r = numericalRound02.Evaluate(value, precision); break; case "0.5": r = numericalRound05.Evaluate(value, precision); break; } return(NumericalFormatProvier.Format(r, precision)); } catch { return(CalcError.Value); } }
public override object Evaluate(object[] args) { try { double value = ArgumentConvert.ToDouble(args[0]); if (List.ContainsKey(value)) { return(List[value]); } return(CalcError.Value); } catch { return(CalcError.Value); } }
public override object Evaluate(object[] args) { int args0 = ArgumentConvert.ToInt(args[0]); double value = 0; switch (args0) { case 15: value = 0.002; break; case 16: case 17: value = 0.003; break; case 18: case 19: value = 0.004; break; case 20: case 21: value = 0.005; break; case 22: case 23: value = 0.006; break; case 24: value = 0.007; break; case 25: value = 0.008; break; } if (value != 0) { return(value); } return(CalcError.Value); }
public override object Evaluate(object[] args) { try { double[] logvalues = new double[7]; logvalues[0] = Math.Log10(ArgumentConvert.ToDouble(args[0])); logvalues[1] = Math.Log10(ArgumentConvert.ToDouble(args[1])); logvalues[2] = Math.Log10(ArgumentConvert.ToDouble(args[2])); logvalues[3] = Math.Log10(ArgumentConvert.ToDouble(args[3])); logvalues[4] = Math.Log10(ArgumentConvert.ToDouble(args[4])); logvalues[5] = Math.Log10(ArgumentConvert.ToDouble(args[5])); logvalues[6] = Math.Log10(ArgumentConvert.ToDouble(args[6])); //y = bx+a double a = (logvalues[3] - logvalues[1]) / (logvalues[2] - logvalues[0]); double b = logvalues[1] - a * logvalues[0]; //y = mx+n double m = (logvalues[5] - logvalues[1]) / (logvalues[4] - logvalues[0]); double n = logvalues[1] - m * logvalues[0]; double logvalue2 = Math.Log10(2); double x1 = (logvalue2 - b) / a; double x2 = (logvalue2 - n) / m; if (Math.Abs(Math.Pow(10, x1) - Math.Pow(10, x2)) > 2) { return(CalcError.Value); } else { //y = gx+h double cv = x1 + (x2 - x1) / 2; double g = (logvalue2 - logvalues[1]) / (cv - logvalues[0]); double h = logvalues[1] - g * logvalues[0]; double z = (logvalues[6] - h) / g; double dz = Math.Pow(10, z); return(NumModifyFunction.Evaluate(new object[] { dz, -1, 0 })); } } catch { return(CalcError.Value); } }
public override object Evaluate(object[] args) { try { List <double> arguments = new List <double>(); arguments.Add(ArgumentConvert.ToDouble(args[0])); arguments.Add(ArgumentConvert.ToDouble(args[1])); arguments.Add(ArgumentConvert.ToDouble(args[2])); double percent = ArgumentConvert.ToDouble(args[3]);//平均数的比例,比如:0.1,0.2 NumericalAverge numericalAverge = new NumericalAvergeByWJJTongMedian(); return(numericalAverge.getResult(arguments.ToArray(), percent)); } catch { return(CalcError.Value); } }
public override object Evaluate(object[] args) { try { DateTime start_date = ArgumentConvert.ToDateTime(args[0]); DateTime end_date = ArgumentConvert.ToDateTime(args[1]); int Days = end_date.Subtract(start_date).Days; if (Days != 0) { return(Days); } } catch { } return(CalcError.Value); }
public override object Evaluate(object[] args) { try { DateTime start_date = ArgumentConvert.ToDateTime(args[0]); DateTime end_date = ArgumentConvert.ToDateTime(args[1]); String type = ArgumentConvert.ToString(args[2]).Trim().ToUpper(); //int hasDecimal = CalcConvert.ToInt(args[3]); double time = 0; TimeSpan ts = end_date.Subtract(start_date); switch (type) { case "D": //天数 time = ts.TotalDays; break; case "H": //小时数 time = (ts.TotalHours < 0 ? ts.TotalHours + 24 : ts.TotalHours); break; case "M": //分钟数 time = (ts.TotalMinutes < 0 ? ts.TotalMinutes + 24 * 60 : ts.TotalMinutes); break; case "S": //秒数 time = (ts.TotalSeconds < 0 ? ts.TotalSeconds + 24 * 3600 : ts.TotalSeconds); break; } if (time != 0) { return(time); } return(DBNull.Value); } catch { throw new InvalidCastException(); } }
public override object Evaluate(object[] args) { try { List <double> arguments = new List <double>(); arguments.Add(ArgumentConvert.ToDouble(args[0])); arguments.Add(ArgumentConvert.ToDouble(args[1])); arguments.Add(ArgumentConvert.ToDouble(args[2])); arguments.Add(ArgumentConvert.ToDouble(args[3])); arguments.Add(ArgumentConvert.ToDouble(args[4])); arguments.Add(ArgumentConvert.ToDouble(args[5])); double percent = ArgumentConvert.ToDouble(args[6]);//平均数的比例,比如:0.1,0.2 -` NumericalAverge numericalAverge = new NumericalAvergeByAverge(); numericalAverge.ComparisonNumber = new AvergeNumber(); return(numericalAverge.getResult(arguments.ToArray(), percent)); } catch { return(CalcError.Value); } }
public override object Evaluate(object[] args) { try { double[] arguments = new double[16]; arguments[0] = ArgumentConvert.ToDouble(args[0]); arguments[1] = ArgumentConvert.ToDouble(args[1]); arguments[2] = ArgumentConvert.ToDouble(args[2]); arguments[3] = ArgumentConvert.ToDouble(args[3]); arguments[4] = ArgumentConvert.ToDouble(args[4]); arguments[5] = ArgumentConvert.ToDouble(args[5]); arguments[6] = ArgumentConvert.ToDouble(args[6]); arguments[7] = ArgumentConvert.ToDouble(args[7]); arguments[8] = ArgumentConvert.ToDouble(args[8]); arguments[9] = ArgumentConvert.ToDouble(args[9]); arguments[10] = ArgumentConvert.ToDouble(args[10]); arguments[11] = ArgumentConvert.ToDouble(args[11]); arguments[12] = ArgumentConvert.ToDouble(args[12]); arguments[13] = ArgumentConvert.ToDouble(args[13]); arguments[14] = ArgumentConvert.ToDouble(args[14]); arguments[15] = ArgumentConvert.ToDouble(args[15]); Array.Sort(arguments); double sum = 0; for (int i = 3; i < 13; i++) { sum = sum + arguments[i]; } return(sum / 10); } catch { return(CalcError.Value); } }
public override object Evaluate(object[] args) { if (args.Length < 3) { return(CalcError.Value); } var avergeHelper = new AvergeNumber(); var n1 = ArgumentConvert.ToDouble(args[0]); var n2 = ArgumentConvert.ToDouble(args[1]); var n3 = ArgumentConvert.ToDouble(args[2]); var numbers = new double[] { n1, n2, n3 }; var difference = MathEx.Max(numbers) - MathEx.Min(numbers); var averge = avergeHelper.getNumber(numbers); var off20 = averge * 0.2; if (difference <= off20) { return(Math.Round(averge, 6)); } else { if (args.Length < 4) { return(CalcError.Value); } var n4 = ArgumentConvert.ToDouble(args[3]); numbers = new double[] { n1, n2, n3, n4 }; averge = avergeHelper.getNumber(numbers); var max = -1d; var exclude = -1d; for (var i = 0; i < numbers.Length; i++) { var m = Math.Abs(numbers[i] - averge); if (max == -1d) { max = m; exclude = numbers[i]; } else { if (m > max) { max = m; exclude = numbers[i]; } } } var result = new List <double>(3); for (var i = 0; i < numbers.Length; i++) { if (numbers[i] != exclude) { result.Add(numbers[i]); } } return(Math.Round(avergeHelper.getNumber(result.ToArray()), 6)); } }