Exemplo n.º 1
0
 public override Value Execute(Args args, Environment environment, SourcePos pos)
 {
     if (args.IsNull("x"))
     {
         return(ValueNull.NULL);
     }
     return(new ValueDecimal((decimal)Math.Sqrt((double)args.GetNumerical("x").GetValue())));
 }
Exemplo n.º 2
0
        public override Value Execute(Args args, Environment environment, SourcePos pos)
        {
            if (args.IsNull("x"))
            {
                return(ValueNull.NULL);
            }
            var digits = 0;

            if (args.HasArg("digits"))
            {
                digits = (int)args.GetInt("digits").GetValue();
            }
            return(new ValueDecimal((decimal)Math.Round((double)args.GetNumerical("x").GetValue(), digits)));
        }
Exemplo n.º 3
0
 public override Value Execute(Args args, Environment environment, SourcePos pos)
 {
     if (args.IsNull("x"))
     {
         return(ValueNull.NULL);
     }
     if (args.IsNull("y"))
     {
         return(ValueNull.NULL);
     }
     if (args.Get("y").IsInt())
     {
         if (args.Get("x").IsInt())
         {
             var  x      = args.GetInt("x").GetValue();
             var  y      = args.GetInt("y").GetValue();
             long result = 1;
             for (int i = 0; i < y; i++)
             {
                 result *= x;
             }
             return(new ValueInt(result));
         }
         else
         {
             var     x      = args.GetDecimal("x").GetValue();
             var     y      = args.GetInt("y").GetValue();
             decimal result = 1;
             for (int i = 0; i < y; i++)
             {
                 result *= x;
             }
             return(new ValueDecimal(result));
         }
     }
     else
     {
         return(new ValueDecimal((decimal)Math.Pow((double)args.GetNumerical("x").GetValue(), (double)args.GetNumerical("y").GetValue())));
     }
 }