Пример #1
0
 public static object LeftShift(int x, object other)
 {
     if (other is int)
     {
         return(LeftShift(x, (int)other));
     }
     else if (other is long)
     {
         return(Int64Ops.LeftShift((long)x, other));
     }
     else if (other is BigInteger)
     {
         return(LongOps.LeftShift(BigInteger.Create(x), other));
     }
     else if (other is bool)
     {
         return(LeftShift(x, (bool)other ? 1 : 0));
     }
     else if (other is ExtensibleInt)
     {
         return(LeftShift(x, ((ExtensibleInt)other).value));
     }
     else if (other is byte)
     {
         return(LeftShift(x, (byte)other));
     }
     return(Ops.NotImplemented);
 }
Пример #2
0
 private static object LeftShift(int x, int y)
 {
     if (y < 0)
     {
         throw Ops.ValueError("negative shift count");
     }
     if (y > 31 ||
         (x > 0 && x > (Int32.MaxValue >> y)) ||
         (x < 0 && x < (Int32.MinValue >> y)))
     {
         return(Int64Ops.LeftShift((long)x, y));
     }
     return(Ops.Int2Object(x << y));
 }
Пример #3
0
 public static object PowerMod(int x, object y, object z)
 {
     if (y is int)
     {
         return(PowerMod(x, (int)y, z));
     }
     else if (y is long)
     {
         return(Int64Ops.PowerMod(x, y, z));
     }
     else if (y is BigInteger)
     {
         return(LongOps.PowerMod(x, y, z));
     }
     return(Ops.NotImplemented);
 }
Пример #4
0
 public static object PowerMod(int x, int y, object z)
 {
     if (z is int)
     {
         return(PowerMod(x, y, (int)z));
     }
     else if (z is long)
     {
         return(Int64Ops.PowerMod(x, y, (long)z));
     }
     else if (z is BigInteger)
     {
         return(LongOps.PowerMod(BigInteger.Create(x), BigInteger.Create(y), (BigInteger)z));
     }
     return(Ops.NotImplemented);
 }