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