Question: You are asked to implement a number of arithmetic methods for SInteger including-add-(addition), sub (subtraction), Ishift (logical shift left) and rshift(arithmetic shift right). You should

You are asked to implement a number of arithmetic methods for SInteger including-add-(addition), sub (subtraction), Ishift (logical shift left) and rshift(arithmetic shift right). You should use the Bit.full_adder method to produce the answer for addition and use add opcrator for subtraction. You can set the carry bit correctly only by using the Bit.full_adder method. Notice that you may need to clear the carry before the operation and sign-extension is required. You do not need to include your Bit class and the global variables (carry, ONE, ZERO and LEN) should submit the whole SInteger class. However, you def lshift (self, k): - -- " Return the shift left of the SInteger by i. The answer has the same number of bits as the original The original SInteger is unmodified." def rshift(self, k): " Return the arithmetic shift right of the Integer by i The answer has the same number of bits as the original The original SInteger is unmodified."" def add (self, other): " Add self to other Both operands must be of the same length. Return the result and set or clear the carry flag." def_ sub (self, other): " self - other Both operands must be of the same length. Return the result and set or clear the carry flag
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
