Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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)
Posted
Updated 1-Mar-15 16:09pm
v3
Comments
Peter Leow 1-Mar-15 9:04am    
Wow, another homework for "us"?
Maciej Los 1-Mar-15 9:14am    
Yeah, smells as "homework" ;)
Sergey Alexandrovich Kryukov 1-Mar-15 22:09pm    
Even if it wasn't homework, we should not "answer" non-questions.
—SA
Maciej Los 1-Mar-15 9:14am    
What have you tried till now? Where are you stuck?
Richard MacCutchan 1-Mar-15 9:22am    
The key part of that post is: Using your program. That is to say, the program you write, not one that someone else does for you.

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900