Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: 2's Complement

  1. May 30, 2010 #1
    Im having some trouble with these conversions, specifically numbers out of the -127 to 128 range, and numbers with bases that are not 10. My book is asking for the 2's complement of -19210 and -458 in 8 bits. Here is my work.


    19210 = 110000002

    (Do I add on another 0 on the left most end here?)

    flipping the bits, I get 001111112

    adding 1 gives 010000002

    the book's answer is 000000102

    how are they getting this?


    For this I tried using the shortcut method and got 458 = 001001012

    flipping the bits and adding 1, I get 110110112

    the book's answer is 101110112

    any help?

    sorry about posting 2 questions in one thread, I just didn't want to clutter the forum with problems that were so similar.
  2. jcsd
  3. May 31, 2010 #2
    Hmm. -192 requires nine bits, unless this is a trick question; but even then, if you assign -192 to a "char" variable in C, the answer is 64, not 2.

    And I agree with your answer for -458.

    What book are you referencing?
  4. May 31, 2010 #3
    The book is "Engineering Problem Solving with C++" second edition, by Delores M. Etter and Jeanine A. Ingber.
  5. May 31, 2010 #4


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Looks like the book converted -4516.
  6. May 31, 2010 #5
    I used Google Books to find the page with the question -- it didn't say anything about the number of bits required (you said 8). I couldn't find the page with the answer, but if it's what you said it is, I don't see how it's right.

    I think vela is right about -4516.

    Maybe you should look for an errata or try to contact the authors.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook