コード例 #1
0
        public override Query VisitSqrtExpression(CalcParser.SqrtExpressionContext context)
        {
            Query q = Visit(context.expression());

            ResultType type = ResultType.Undefined;

            if (q.ExpectedResult == ResultType.Number)
            {
                type = ResultType.Number;
            }

            return(new Query($"SQRT({q})", type));
        }
コード例 #2
0
        public override Argument VisitSqrtExpression(CalcParser.SqrtExpressionContext context)
        {
            Argument arg = Visit(context.expression());

            if (arg.IsNull)
            {
                return(Argument.Null);
            }

            if (arg.IsDouble)
            {
                return(new Argument(Math.Sqrt(arg.ToDouble())));
            }

            throw ArgumentCastException.Create("double", arg);
        }