Exemple #1
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())));
     }
 }