예제 #1
0
        /// <summary>
        /// Executes this expression.
        /// </summary>
        /// <param name="parameters">An object that contains all parameters and functions for expressions.</param>
        /// <returns>
        /// A result of the execution.
        /// </returns>
        /// <seealso cref="ExpressionParameters" />
        public override object Execute(ExpressionParameters parameters)
        {
            var arg    = (double)Argument.Execute(parameters);
            var digits = Digits != null ? (int)(double)Digits.Execute(parameters) : 0;

            return(Math.Round(arg, digits, MidpointRounding.AwayFromZero));
        }
예제 #2
0
파일: Round.cs 프로젝트: suigin500/xFunc
        /// <summary>
        /// Executes this expression.
        /// </summary>
        /// <param name="parameters">An object that contains all parameters and functions for expressions.</param>
        /// <returns>
        /// A result of the execution.
        /// </returns>
        /// <seealso cref="ExpressionParameters" />
        public override object Execute(ExpressionParameters parameters)
        {
            var argResult = Argument.Execute(parameters);

            if (argResult is double arg)
            {
                var digits = Digits?.Execute(parameters);

                return(Math.Round(arg, (int)((digits as double?) ?? 0), MidpointRounding.AwayFromZero));
            }

            throw new ResultIsNotSupportedException(this, argResult);
        }