Exemplo n.º 1
0
        public static object RightShift(int x, object other)
        {
            if (other is int)
            {
                return(RightShift(x, (int)other));
            }
            else if (other is BigInteger)
            {
                return(LongOps.RightShift(BigInteger.Create(x), other));
            }
            else if (other is bool)
            {
                return(RightShift(x, (bool)other ? 1 : 0));
            }
            else if (other is long)
            {
                long y = (long)other;
                if (y < 0)
                {
                    throw Ops.ValueError("negative shift count");
                }
                if (y >= Int32.MaxValue)
                {
                    return(x > 0 ? 0 : 1);
                }
                return(RightShift(x, (int)y));
            }
            else if (other is ExtensibleInt)
            {
                return(RightShift(x, ((ExtensibleInt)other).value));
            }
            else if (other is byte)
            {
                return(RightShift(x, (byte)other));
            }

            return(Ops.NotImplemented);
        }