Computer Architecture and Design Question:
Download Questions PDF

Convert a number to its twos compliment and back?

Answers:

Answer #1
First convert a number into binary format. Then keep last binary number as it is & complement all others.
Eg:- 1101001

2's Compl:0010111

Answer #2
The above stated method fails for 11000. Otherwise we can use a method which is when the last bit is 0 check the next bit towards the left, if it is a 0 again then check the preceding bit, if it is 1 keep aside the bits after this one and the one itself and invert the rest of the bits.

Download Computer Architecture Interview Questions And Answers PDF

Previous QuestionNext Question
Convert 65(Hex) to Binary?The CPU is busy but you want to stop and do some other task. How do you do it?