示例#1
0
        public static IntegerNumber operator <<(IntegerNumber x, int shift)
        {
            if (shift == 0)
            {
                return(x);
            }
            if (shift < 0)
            {
                return(x >> (-shift));
            }

            int xlen             = x.RealDigits;
            int resultDigits     = xlen + (shift >> 6);
            int singleDigitShift = shift & 63;

            if (singleDigitShift != 0)
            {
                long hix = (long)x.bits[xlen - 1] >> (63 - singleDigitShift);
                if (hix != 0L && hix != -1L)
                {
                    resultDigits++;
                }
            }
            ulong[] result = x.bits;
            ExtendToExact(ref result, resultDigits, true);
            AsmX64Operations.IntShl(result, shift, resultDigits);
            return(new IntegerNumber(result, false));
        }