Exemplo n.º 1
0
        public static eeNumber RShift(eeNumber num1, eeNumber num2)
        {
            if (num1.IsFrac() || num2.IsFrac())
            {
                throw new Exception("Cannot shift a non-int or by a non-int");
            }

            List <bool> bin1 = num1.ToBinary();

            for (eeNumber i = ZERO.Copy(); i < num2; i += ONE)
            {
                bin1.RemoveAt(bin1.Count() - 1);
            }

            return(FromBinary(bin1.ToArray()));
        }
Exemplo n.º 2
0
        public static eeNumber LShift(eeNumber num1, eeNumber num2)
        {
            if (num1.IsFrac() || num2.IsFrac())
            {
                throw new Exception("Cannot shift a non-int or by a non-int");
            }

            List <bool> bin1 = num1.ToBinary();

            // trim the tail
            //for (eeNumber i = ZERO.Copy(); i < num2; i += ONE)
            //    bin1.RemoveAt(bin1.Count() - 1);

            // add to the front
            for (eeNumber i = ZERO.Copy(); i < num2; i += ONE)
            {
                bin1.Add(false);
            }

            return(FromBinary(bin1.ToArray()));
        }