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: Hexadecimal conversion

  1. Apr 15, 2012 #1
    1. The problem statement, all variables and given/known data

    Write all the possible decimal values (3 of them) of the 8-bit hexadecimal number 0xD1.

    3. The attempt at a solution
    So I can write that D1 = D*161 + 1 * 160 = 13*16 + 1 = 209

    Can I also say that the most significant bit is reserved for sign? In that case, I think the D would indicate a negative value (is that right? What's the cutoff for positive/negative signed values in hexadecimal?) Thus, I would have: - (1 * 160) = -1

    The only other interpretation I can think of is to say that D1 is a complement, so I'd have to convert to binary and then convert to decimal. So:

    D1 = 1101 0001, then I take all the places where the value is zero and add. Doing so gives: 2 + 4 + 8 + 32 = 46

    I also have to add one to 46, I believe. So my answer is 47. Is that so?
     
  2. jcsd
  3. Apr 15, 2012 #2

    HallsofIvy

    User Avatar
    Science Advisor

    "most significant bit reserved for sign"? What, exactly, is the statement of the problem? "Most significant bit" would refer to a memory location in a computer but the question you ask, converting a hexadecimal number to decimal, doesn't necessarily have anything to do with computers.
     
  4. Apr 15, 2012 #3

    SammyS

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member

    If the most significant bit is used for the sign, then looking at D in binary 1101, indicates that 0xD1 is the negative of 0x51 ...

    I think there's another way to interpret this number for the negative case --- in which the representation sort of wraps around zero like a mod function. What do you need to add to 0xD1 to get 0x100 ? ... 47. That would make this -47.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook