Addition using 8-bit binary numbers with an 8-bit result

Discussion in 'Homework Help' started by jegues, Dec 8, 2010.

  1. jegues

    Thread Starter Well-Known Member

    Sep 13, 2010
    735
    43
    Given the following base 10 values:

    a) 48 + 87

    b) 48 + (-87)

    c) -48 + (-87)

    Preform the operations using 8-bit binary numbers and generate and 8-bit result. Clearly show the sum and carry generated. Also, indicate if an overflow condition has occured.

    See figure attached for my work. Can someone verify if I'm doing this correctly?

    Also if I want to indicate my negative result in two's complement do I need to invert all the bits again excluding the first 1 or do I keep as indicated in the figure? (i.e. Result in b) and c) )

    Thanks again!
     
    • 07Q8.jpg
      07Q8.jpg
      File size:
      271.7 KB
      Views:
      72
  2. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Your operations are correct as far as I can see.

    Your last result is negative as a signed negative number, because all the bits, from bit 8 and after (to the left) are 1s (with sign extension). You can't judge by the bit 7 bit because of the overflow of the adder.

    In an 8-bit adder that result would be compromised and turned into 121 due to the loss of the first 1.
    Therefore, it is essential to retain the carry in binary operations.
     
  3. jegues

    Thread Starter Well-Known Member

    Sep 13, 2010
    735
    43
    I'm confused as to what you're trying to tell me about my last result. Is overflow occuring, is it incorrect?

    Can you clarify?
     
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Your initial numbers have 8-bits max, right? I start counting them from bit 0, the LSB, and reach up to bit 7.

    If you do the addition and an overflow occurs (bit 8 is 1), that means that your 8-bit result is no longer valid. You need to look now at all of the nine bits to get the right result.

    Of course, as you work with 2's complement and the 9-bit result starts with an 1, it is negative.
     
  5. jegues

    Thread Starter Well-Known Member

    Sep 13, 2010
    735
    43
    Can't we also look at the carrys to determine overflow as well?

    If we have a n-1 bit number then we simply xor the carries (Cn-1 xor Cn)

    If this condition is satisfied, we have overflow.
     
  6. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Typically you have a set number of digits for your actions. Adders come in 4-bits or 8-bits in commercial IC's. You can build your own of course but I think that's impractical.

    If you are set to recognize the negative numbers, you could look both at the carry out and the MSB. If at least one of them is 1, you can safely assume the number is negative.
     
  7. nyasha

    Active Member

    Mar 23, 2009
    90
    1
    Your last operation is not correct. There is arithmetic overflow that is why its not correct.
     
  8. Letech

    New Member

    Dec 12, 2010
    10
    0
    I think the operations that Jegues attached were all performed correctly and there is no mistakes on them.

    Now my question or my wonder if you like is:
    How do you convert 11011001 to decimal?
    Referring to the picture that Jegues attached, when he tried to perform the subtraction of ( 48-87) in binary, you get totally different answer if you compare it to the value that you get when you perform the subtraction in decimal.

    If you convert (11011001) by multiplying each bit by 2^n and then add them together you will end up getting 217 instead of -39. I know that 48 + (-87)=-39.

    00110000-01010111 = 11011001
    48-87 = -39

    Shouldn't (00110000) - (01010111) must be equal to (48) - (87) ?!
    If that was true,
    then why when you convert (11011001) to decimal you don't get -39?

    Is there something missing here or what?
     
  9. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    Because the result is negative and encoded in 2's complement. Invert the digits and add 1 to find the absolut value of the result.

    Wiki "two's complement" for more info.
     
Loading...