private BitArray Modulo() //14 { var result = FirstOperand.ToInt() % SecondOperand.ToInt(); ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght); return(ThirdOperand); }
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); }
private BitArray StrongDivision() //13 { var result = FirstOperand.ToInt() / SecondOperand.ToInt(); ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght); return(ThirdOperand); }
private BitArray Multiplication() //12 { var result = FirstOperand.ToInt() * SecondOperand.ToInt(); ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght); return(ThirdOperand); }
private BitArray Subtraction() //11 { var result = FirstOperand.ToInt() - SecondOperand.ToInt(); ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght); return(ThirdOperand); }
private BitArray Addition() //10 { var result = FirstOperand.ToInt() + SecondOperand.ToInt(); ThirdOperand = BitArrayExtension.GetBitArray(result, OperandLenght); return(ThirdOperand); }
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)); }
private BitArray Insert() //16 { var position = SecondOperand.ToInt(); var inRange = position < 9 && position >= 0; if (!inRange) { position %= OperandLenght; } FirstOperand[position] = ThirdOperand[position]; return(FirstOperand); }
private string GetStringCommand() { string command = ThirdOperand.ToInt() + " " + SecondOperand.ToInt() + " " + FirstOperand.ToInt() + " " + Operation.ToInt(); return(command); }
private BitArray CycleShiftR() //23 { ThirdOperand = new BitArray(FirstOperand); ThirdOperand = ThirdOperand.CycleShiftR(SecondOperand.ToInt()); return(ThirdOperand); }
private BitArray ShiftL() //20 { ThirdOperand = new BitArray(FirstOperand); ThirdOperand = ThirdOperand.ShiftL(SecondOperand.ToInt()); return(ThirdOperand); }
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); }