1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Converting decimal number to binary IEEE 754 32-bit single-precision then hexadecimal

  1. Jan 27, 2013 #1

    s3a

    User Avatar

    1. The problem statement, all variables and given/known data
    Convert the decimal number 2000.90210 to a single-precision IEEE 754 hexadecimal.

    2. Relevant equations
    (exponent field)_10 - 127_10 = exponent_10
    The first bit is the sign bit.
    The 2nd to 9th bits are the exponent bits.
    The 10th to 32nd bits are the fraction field bits.
    1.(fraction field)_2 x 2^(exponent_10) leads to the base 10 final answer

    3. The attempt at a solution
    My attempt at the solution is attached as MyWork.jpg.

    I was planning to convert it to the binary IEEE 754 32-bit single-precision representation since that's what I am familiar with and then convert it to hexadecimal however, it seems that when I do this, my binary version is far off from the decimal value I'm initially given.

    I'm not sure but, this might be related to the fact that the binary fraction field is (at least, seemingly) irrational.

    Any help in solving this problem would be greatly appreciated!
     

    Attached Files:

  2. jcsd
  3. Jan 27, 2013 #2

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    Rational <-> irrational is independent of the base you express a number in. There is no exact representation of the number with a finite number in base 2, but that does not matter. It just gives a small rounding error.

    In which way?
    Your attempt looks fine.
     
  4. Jan 27, 2013 #3

    s3a

    User Avatar

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    Hello.

    Alright.

    When I input my binary IEEE 754 answer to this ( http://www.h-schmidt.net/FloatConverter/IEEE754.html ) website, the decimal representation is around 4001.80. If it's not my work that's wrong, what's wrong with the Java applet software or with the way I am “communicating” with it?
     
  5. Jan 27, 2013 #4

    rcgldr

    User Avatar
    Homework Helper

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    so this means
    (exponent field)_10 = exponent_10 + 127_10

    if exponent_10 is 127, then what should (exponent field)_10 be?
     
  6. Jan 27, 2013 #5

    s3a

    User Avatar

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    The equation is (exponent field)_10 = exponent_10 – 127_10. (Notice the – instead of a +.) I did do that in my work, however. So, why is the Java applet software disagreeing strongly with me?
     
  7. Jan 27, 2013 #6

    rcgldr

    User Avatar
    Homework Helper

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    From your first post:

    start with the equation from your first post:

    (exponent field)_10 - 127_10 = exponent_10

    then add 127_10 to both sides:

    (exponent field)_10 = exponent_10 + 127_10
     
  8. Jan 27, 2013 #7

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    I would not call this "far off", it is exactly a factor of 2, indicating a problem with the exponent. rcgldr found the error.
     
  9. Jan 27, 2013 #8

    s3a

    User Avatar

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    Good point, mfb. I just noticed that.

    And, rcgldr, that was just what I needed to fix my entire answer to the problem.

    Thank you both!
     
  10. Jan 27, 2013 #9

    s3a

    User Avatar

    Re: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadec

    Good point, mfb. I just noticed that.

    And, rcgldr, that was just what I needed to fix my entire answer to the problem.

    Thank you both!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Converting decimal number to binary IEEE 754 32-bit single-precision then hexadecimal
Loading...