1
$\begingroup$

I am finishing an assignment related to complement calculations. The question is as follows:

Convert the following decimal numbers to eight-bits binary and perform the subtraction by using ones' and twos' complement arithmetic.
28 - 41 

By using 1s complement I can get the answer -13 with the workings below

  0 0 0 1 1 1 0 0
+ 1 1 0 1 0 1 1 0
------------------
  1 1 1 1 0 0 1 0

Signed-magnitude in Binary: 10001101
Decimal representation: -13

For 2s complement, I understand that I should add 1 after replacing the digits but when I do the calculation, the answer doesn't make sense at all.

00101001 ---> 11010110 (Ones complement) ---> 11010111 (Twos complement)

  0 0 0 1 1 1 0 0
+ 1 1 0 1 0 1 1 1 
-----------------
  1 1 1 1 0 0 1 1

Signed-magnitude in Binary: 10001100
Decimal representation: -12

This is most likely caused by the addition of 1. But referring to the lecture notes and the online tutorials I don't think I should make a subtraction afterwards. Did I do anything wrong during the calculation? :-(

$\endgroup$
1
$\begingroup$

You need to consider your result as twos complement as well, so subtract $1$, getting $11110010_2$, then complement, getting $1101_2=13_{10}$ Arithmetic works staying withing twos complement.

$\endgroup$
  • $\begingroup$ courses.cs.vt.edu/~csonline/NumberSystems/Lessons/… According to the webpage that I have recently found on the internet, I can't think of any reason why he could get the correct answer without subtracting 1. In what circumstance should I need to make a subtraction? $\endgroup$ – mightyheptagon Sep 25 '13 at 6:18
  • 1
    $\begingroup$ @KahoFung: the basic calculation is done whitout subtracting $1$. The subtract $1$ only comes in when converting back to decimal. $\endgroup$ – Ross Millikan Sep 25 '13 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.