Monday, September 21, 2015

(IGNOU MCA 031 SOLVED Q.2)Write a program for the arithmetic negation of an integer, addition, subtraction and multiplication of two integers using 3’s complement representation.

Suppose that instead of binary or decimal representation of integers, we have ternary, along with 3’s complement, representation of integers, i.e., integers are represented using three digits, viz., 0, 1,2. For example, the integer 47 is represented as 01202  =  (in decimal)    1. 33 + 2. 32 + 0. 31 + 2. 30, where, the leading zero indicates positive sign.  And the integer (- 47 ) in 3’s complement is represented by   11021, the leading 1 indicates negative sign. The other digits, except the right-most, in the representation of (−   47) are obtained by subtracting from 2 the corresponding digit in 47’s representation, and then adding 1 (the representation of – 47 is obtained as 11020 + 00001).