2

I'm currently trying to convert the following IEEE 754 hex number 0x805c00f0 to its decimal equivalent which according to online converters is about -8.44920195816662938E-39. Working it out on paper step-by-step, I get the following:

805c00f0 = 1000 0000 0101 1100 0000 0000 1111 0000 Leftmost 1 means the number is negative. The next eight bits, 000 0000 0 means an exponent of -127 after subtracting the bias. I'm left with bits 101 1100 0000 0000 1111 0000, the mantissa.

After recalling the implicit 1, I have -1.101 1100 0000 0000 1111 0000 * 2^-127. Moving the decimal point to the left 127 places, I have -0.00(...)1101 1100 0000 0000 1111 0000. Summing up, I get -1(2^(-127)+2^(-128)+2^(-130)+2^(-131)+2^(-132)+2^(-143)+2^(-144)+2^(-145)+2^(-146)) = -1.01020727331947522E-38. This is not equal to what converters have given me and I cannot understand why. What am I getting wrong?

2
  • For what it's worth, I used binaryconvert.com/result_float.html?hexadecimal=805C00F0 to check my answer Commented Feb 19, 2014 at 2:49
  • If you guys are stumped too, that's okay. I'd like to at least hear from you as you ponder this. Commented Feb 19, 2014 at 3:08

1 Answer 1

2

per wikipedia "The stored exponents 00 and FF are interpreted specially." and the formula to use is (−1)^(signbits)×2^(−126)×0.(significandbits)

805c00f0 => 8 0 5 c 0 0 f 0 => 1000 0000 0101 1100 0000 0000 1111 0000 => 1 00000000 101 1100 0000 0000 1111 0000 => -1 x 2^(-126) x 0.10111000000000011110000 => -1 x 2^(-126) x (2^-1 + 2^-3 + 2^-4 + 2^-5 + 2^-16 + 2^-17 + 2^-18 + 2^-19) => -1 * (2^-127 + 2^-129 + 2^-130 + 2^-131 + 2^-142 + 2^-143 + 2^-144 + 2^-145) => -8.449202e-39 
Sign up to request clarification or add additional context in comments.

1 Comment

I see. So when exponent is either 00000000 or ffffffff, we handle it differently?.. Gonna need to study this. Thank you so much!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.