Im working on this question:

Consider a 32-bit hexadecimal number stored in memory as 1B08C22B. If the number is an IEEE single-precision floating point value, determine the decimal equivalent of the number (you may leave your answer in scientic notation form, as a number times a power of two).

And I have managed to get the following answer is it correct? enter image description here

  • 2
    \$\begingroup\$ You interpreted the number as a (signed or unsigned) binary number. But the question says it's in IEEE 32-bit floating point format, so the bits have a totally different (and quite a bit more complicated) meaning. \$\endgroup\$ – Wouter van Ooijen Feb 4 '17 at 22:23
  • \$\begingroup\$ probably the quickest reference to IEEE-754 is the Wikipedia article. \$\endgroup\$ – robert bristow-johnson Feb 4 '17 at 23:07

First convert it to binary:

0001 1011 0000 1000 1100 0010 0010 1011

Then map it to its fields:

0 00110110 00010001100001000101011
S exponent -------mantissa--------

\$S=0\$ so the value is positive.

The exponent is stored in excess-127 notation, which simply means they wanted negative magnitudes to sort smaller than positive magnitudes when the sort routine treats the entire value as an unsigned. To fix that, treat the exponent as an unsigned binary value, turn it into decimal, then subtract 127. This means you have an exponent of -73, if I did my mental conversion correctly. So the power is \$2^{-73}\$.

The mantissa uses hidden bit format if its not de-normalized (and it's not.) So you need to prefix "1." to the mantissa, to make 1.00010001100001000101011 as the final value. (They had removed that prefix before packing the number into the format so you have to prefix it back in.)

This means your number is \$1.00010001100001000101011\cdot 2^{-73}\$. That equals \$2^{-73}+2^{-77}+2^{-81}+2^{-82}+2^{-87}+2^{-91}+2^{-93}+2^{-95}+2^{-96}\$ or approximately \$+1.13123954\times 10^{-22}\$ in decimal.

|improve this answer|||||
  • \$\begingroup\$ Upvote because you didn't simply present the EXP version. Your description was very valuable. \$\endgroup\$ – SDsolar Feb 20 '17 at 4:16

Not correct. You are treating this value as an unsigned integer.

I believe that 32-bit single-precision floating point format uses bit 31 as a sign bit, bits 30-23 as an offset-binary exponent, and bits 22-0 as a fractional value.

In you case, the sign bit indicates a negative value. You should review this format and recalculate.

|improve this answer|||||
  • \$\begingroup\$ I see your point and you make a good one. I think that is why @Jonk broke it down to the bits to answer that precise question. No vote because you flatly declared the OP as not correct. \$\endgroup\$ – SDsolar Feb 20 '17 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.