Ejemplo n.º 1
0
 public override RuntimeResult Exponent(Value other)
 {
     if (other.Type == ValueType.INTEGER)
     {
         return(new RuntimeResult(new BigInt(System.Numerics.BigInteger.Pow((System.Numerics.BigInteger)Data, (int)other.Data)).SetPositionAndContext(Position, Context)));
     }
     else if (other.Type == ValueType.INT64)
     {
         return(new RuntimeResult(Util.BigPow((System.Numerics.BigInteger)Data, (long)other.Data).SetPositionAndContext(Position, Context)));
     }
     else if (other.Type == ValueType.BIGINTEGER)
     {
         return(new RuntimeResult(Util.BigPow((System.Numerics.BigInteger)Data, (System.Numerics.BigInteger)other.Data).SetPositionAndContext(Position, Context)));
     }
     else if (other.Type == ValueType.FLOAT)
     {
         double exp = (double)other.Data;
         if ((System.Numerics.BigInteger)Data < 0 && Math.Floor(exp) != exp)
         {
             Value complex = Cast(ValueType.COMPLEX);
             if (complex != null)
             {
                 return(complex.Exponent(other));
             }
         }
         return(new RuntimeResult(Util.BigPow((System.Numerics.BigInteger)Data, (double)other.Data).SetPositionAndContext(Position, Context)));
     }
     return(new RuntimeResult(new RuntimeError(Position, "'-' is unsupported between " + Type.ToString().ToLower() + " and " + other.Type.ToString().ToLower(), Context)));
 }