Пример #1
0
        private BitArray Modulo() //14
        {
            var result = FirstOperand.ToInt() % SecondOperand.ToInt();

            ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght);
            return(ThirdOperand);
        }
Пример #2
0
        private BitArray ReadInBase() //18
        {
            var bs      = SecondOperand.ToInt();
            var operand = GetStringFromDialog();

            if (bs > 36 || bs < 0)
            {
                return(BitArrayExtension.GetBitArray(0, 9));
            }
            try
            {
                operand = operand.ToUpper();

                int result = 0;
                for (int i = operand.Length - 1, mul = 0; i >= 0; i--, mul++)
                {
                    result += (int)Math.Pow(bs, mul) * (Char.IsDigit(operand[i]) ?
                                                        (int)Char.GetNumericValue(operand[i]) :
                                                        (operand[i] - 55));
                }
                FirstOperand = BitArrayExtension.GetBitArray(result, OperandLenght);
            }
            catch (Exception)
            {
                return(BitArrayExtension.GetBitArray(0, 9));
            }
            return(FirstOperand);
        }
Пример #3
0
        private BitArray StrongDivision() //13
        {
            var result = FirstOperand.ToInt() / SecondOperand.ToInt();

            ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght);
            return(ThirdOperand);
        }
Пример #4
0
        private BitArray Multiplication() //12
        {
            var result = FirstOperand.ToInt() * SecondOperand.ToInt();

            ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght);
            return(ThirdOperand);
        }
Пример #5
0
        private BitArray Subtraction() //11
        {
            var result = FirstOperand.ToInt() - SecondOperand.ToInt();

            ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght);
            return(ThirdOperand);
        }
Пример #6
0
        private BitArray Addition() //10
        {
            var result = FirstOperand.ToInt() + SecondOperand.ToInt();

            ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght);
            return(ThirdOperand);
        }
Пример #7
0
        private BitArray GetNumInSecOperandBase() //17
        {
            var num = FirstOperand.ToInt();
            var bs  = SecondOperand.ToInt();

            if (bs > 36 || bs < 0)
            {
                ShowMessage("Incorrect Base");
                return(BitArrayExtension.GetBitArray(0, 9));
            }

            ShowMessage(ConvertToBase(num, bs));
            return(BitArrayExtension.GetBitArray(num, 1));
        }
Пример #8
0
        private BitArray Insert() //16
        {
            var position = SecondOperand.ToInt();

            var inRange = position < 9 && position >= 0;

            if (!inRange)
            {
                position %= OperandLenght;
            }

            FirstOperand[position] = ThirdOperand[position];

            return(FirstOperand);
        }
Пример #9
0
        private string GetStringCommand()
        {
            string command = ThirdOperand.ToInt() + " " + SecondOperand.ToInt() + " " + FirstOperand.ToInt() + " " + Operation.ToInt();

            return(command);
        }
Пример #10
0
 private BitArray CycleShiftR() //23
 {
     ThirdOperand = new BitArray(FirstOperand);
     ThirdOperand = ThirdOperand.CycleShiftR(SecondOperand.ToInt());
     return(ThirdOperand);
 }
Пример #11
0
 private BitArray ShiftL() //20
 {
     ThirdOperand = new BitArray(FirstOperand);
     ThirdOperand = ThirdOperand.ShiftL(SecondOperand.ToInt());
     return(ThirdOperand);
 }
Пример #12
0
        private BitArray GetOperandsList() //0
        {
            var bs = FirstOperand.ToInt();

            if (bs > 36 || bs < 2)
            {
                ShowMessage("Incorrect Base");
                return(null);
            }

            string result = ConvertToBase(ThirdOperand.ToInt(), bs) + "  " + ConvertToBase(SecondOperand.ToInt(), bs) + "  " +
                            ConvertToBase(FirstOperand.ToInt(), bs) + "  " + ConvertToBase(Operation.ToInt(), bs);

            ShowMessage(result);
            return(null);
        }