/// <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)); }
/// <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); }