 This is Vishwanath Chauhan, Assistant Professor, Department of Computer Science and Engineering, Valtran Institute of Technology, Solapur. Now I am here to explain the integer arithmetic. At the end of this session, the students will be able to understand the arithmetic operations on integers. So let us have a glance on how ALU works, then integer representation, then we will see the arithmetic operations on integer. Integer arithmetic. The ALU plays a very important role to perform the arithmetic operations on integer. This arithmetic and logic unit has two inputs, mainly the operand registers through which the operands are fed as a input to perform the operations. And the operations are controlled by the respective control signals. So after performing the operations such as arithmetic and logical operations on given operands, it will generate the result and result may be stored in registers or memory. So after performing arithmetic operations, the respective flags are going to set or reset. Now let us see how to represent the integer. The first method which is sine magnitude representation. So in general, for a given n bit sequence of binary number, we can find its magnitude as follows. Let us consider the given number, binary number is having the positions a0, a1, a2, so on up to a minus n minus 2 and last bit is a n minus 1. For this range, the magnitude of this binary digit is equal to, according to this formula, is equal to summation of 2 raised to i, a i, where i is varying from 0 to n minus 1. So let us consider the example 1, 1, 1, 1, 1, 1, 1, 1. So this example leaves its decimal value which is equal to 255 according to this formula. So magnitude is 255. This is what sine magnitude representation. So let us expand further. There are several convenience used to represent negative as well as positive integers. So these numbers may be positive or negative. So those can be represented like this. If the sine bit is 0, then it represents positive. If it is 1, it represents negative number. So plus 18 is equal to 0, 0, 0, 1, 0, 0, 1, 0. So this leftmost 0 indicates positive. Similarly, the negative number minus 18 can be represented as leftmost bit as 1 and other bit remains as it is. So this is the general case. Through this formula, the magnitude can be formed. For positive number, a n minus 1 is equal to 0 and this is the magnitude to find the number. Similarly, if number is negative, then a of n minus 1 bit should be 1 and the rightmost bit magnitude can be formed with the help of this formula, which is summation of 2 raise to i, a i, where i is varying from 0 to n minus 2 in both case positive and negative. Let us consider the second method which is two's complement representation. The two's method, two's complement method of a given n bit number is defined as its complement plus 1 for the range 2 raise to n. Let us consider a 3-bit number, say 0, 1, 0. So whose two's complement can be formed like this. First complement, which is 1, 0, 1, plus 1, which leads 1, 1, 0. So that's like this, represent minus 6 in two's complement. So this is an example. So first represent plus 6 as 0, 1, 1, 0. Take the two's complement, which is 1, 0, 0, 1. Then add 1 to complement of this number. Then we'll get minus 6, which is equal to 1, 0, 1, 0. So let us see the characteristics of two's complement representation. So the number range varies from minus 2 raise to n minus 1 to 2 raise to n minus 1 minus 1 for a given n-bit number. So expansion of bit length. Add additional bit position to the left and fill in which the value of the original integer. Having overflow rule, if two numbers with the same sign, either it may be positive or negative are added, then overflow occurs if and only if the result is having opposite sign. Substraction rule, which is required to find the subtraction of a given two numbers. To subtract b from a, so we need to find the two's complement of b, then add it to a. So we'll get the subtraction. So these are the three characteristics of two's complement. Pause this video, think and write the answer for this question. The question is how to represent single magnitude representation of integer and two's complement representation of integer. I hope your answer for this question. The answer is like this. Sign magnitude number can be represented. If the sign bit is 0, then it indicates the number is positive. If it is 1, it indicates negative. And two's complement can be found like this, take the two, one's complement of given number, then add one, we'll get it, two's complement. So coming to integer arithmetic, first operation, negation. Negation can be found by sign magnitude representation. The rule for forming the negation of given integer is very simple. Just have a invert of sign bit, we'll get it. Two's sign binary number, which is equal to say plus 53. So this is plus 53. So sign indicates plus negative minus 53, here sign is one. So two's complement method in which as we saw in previous slide, take the complement of given number, then add one. Negation of integer can be formed by taking Boolean complement of each bit of integer, treating the result as unsigned binary integer. Plus 18, bitwise complement, add one, we'll get minus 18, which is negation of a given number. Addition and subtraction. So register A is giving the input to add a subtractor, B is second operand. So this is switch, if switch is equal to zero, content of B register is copied forwarded to adder, if it is one, it takes complement of B and it will forward to adder. So if switch is equal to one, then one's complement plus the switch content one will be added, which forms negation of a given number, then it leads subtraction. So which uses the basic operation XOR, if two inputs are same, result is zero, else one. So if you XOR a given number with zero, you will get same number, if you XOR the given number with one, we'll get the one's complement. So this concept is used here to take the complement of a given number. So which helps for subtraction. So this same circuit is going to perform addition as well as subtraction. So next multiplication, both algorithm. So take multiplicand m, multiplier q, initialize register A is equal to zero, then insert zero to q minus one position, initially initialize the count, which is equal to n. So if q zero and q one are zero, zero and perform a plus m, if q zero and q minus one are either one, one or zero, zero, then directly go for arithmetic shift right of A, q and minus one, increase the count, decrement the count. So this will keep on repeating. If q zero and q minus one is equal to one zero, go for subtraction. At the end, we'll get, if count is equal to zero, get the result. For division, go for restoring method and non restoring method. These are the references, thank you.