See more:
(untagged)
Suppose that instead of binary or decimal representation of
integers, we have a representation using 5 digits, viz. 0,1,2,3,4,
along with 5’s complement, representation of integers. For
example, the integer 147 is represented as (01042)5 = (in
decimal) + 1. 53 + 0. 52 + 4. 51 + 2. 30, where the leading zero
indicates positive sign.
And the integer ( -147 ) in 5’s complement is represented by
13403, the leading 1 indicates negative sign. The other digits,
except the right-most, in the representation of ( – 147) are obtained
by subtracting from 4 the corresponding digit in 147’s
representation, and then adding 1 (the representation of –147 is
obtained as 13402 + 00001).
Write a program for the arithmetic (negation of an integer, addition,
subtraction and multiplication of two integers) of integers using 5’s
complement representation. The program should include a
procedure for calculating each of negation of an integer, addition,subtraction and multiplication of two integers. The integers will use
8 5-digit positions, in which the left-most position will be used for
sign.
Using your program find the 5-digit representation of each of the
decimal numbers/ expression: 345, -297, 18 and
((345-297) * 18)