0
\$\begingroup\$

I have a problem of adding two numbers in base of two's complement (6 bits!!!)

1100(2's C) + 0101(2's C)

I notice that the first number is starting with 1 which means it's negative but since it's 6 bits, I have to change those two numbers into 6 bits and I have no clue how to find those numbers in 6 bits..

I need help please

Thank You

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Has your professor covered sign-extension yet? \$\endgroup\$
    – AaronD
    Commented Feb 23, 2015 at 20:53
  • \$\begingroup\$ No never heard of them \$\endgroup\$
    – Jack
    Commented Feb 23, 2015 at 20:54
  • \$\begingroup\$ Just have to use the two's complement \$\endgroup\$
    – Jack
    Commented Feb 23, 2015 at 20:54
  • 1
    \$\begingroup\$ Okay. Google it then. Now that you have the term, it should solve your problem. \$\endgroup\$
    – AaronD
    Commented Feb 23, 2015 at 20:55
  • \$\begingroup\$ Just extend it to the left as much as needed, replicating the leftmost bit (sign bit). \$\endgroup\$
    – Eugene Sh.
    Commented Feb 23, 2015 at 20:56

1 Answer 1

2
\$\begingroup\$

1100 in four bits is -4

extending this to 6 bits, do sign extension to the left, adding 1's because the left bit above is 1, and get 111100

this is still -4 in two's complement

0101 is 5 in decimal

extending it to the left, adding 0's, because the left bit is 0, and get 000101

adding these two together:

 111100
 000101
 ======
1000001

the carry bit (first one on the left) is discarded.

The result then is just 1, which matches adding in decimal, -4 + 5 = 1.

\$\endgroup\$
1
  • \$\begingroup\$ The truncated left most bit in your calculation result is not overflow. It's Carry (out). \$\endgroup\$
    – Paebbels
    Commented Feb 23, 2015 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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