Esempio n. 1
0
        /// <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)
        {
            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
            {
                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 -`
                int    valideCount = ArgumentConvert.ToInt(args[7]);    //平均数的比例,比如:0.1,0.2 -`

                NumericalAverge numericalAverge = new NumericalAvergeByAverge();
                numericalAverge.ComparisonNumber = new AvergeNumber();
                return(numericalAverge.getResultGeneral(arguments.ToArray(), percent, valideCount));
            }
            catch
            {
                return(CalcError.Value);
            }
        }