Ejemplo n.º 1
0
        public override Query VisitSgnExpression(CalcParser.SgnExpressionContext context)
        {
            Query q = Visit(context.expression());

            ResultType type = ResultType.Undefined;

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

            return(new Query($"SGN({q})", type));
        }
Ejemplo n.º 2
0
        public override Argument VisitSgnExpression(CalcParser.SgnExpressionContext context)
        {
            Argument arg = Visit(context.expression());

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

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

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