Johnny Riley
Johnny Riley

Reputation: 41

Converting to IEEE 754 Single precision floating-point format help

How would the number 0.1011 * 2-101 be represented in this format?

I am assuming the exponent would be -101, and the fraction would be 1011.

So the number would be :

The sign : 1 (since is is -101).
The exponent : 101 in binary, which is: 

    101/2= 50 R1
    50/2 = 25 R0
    25/2 = 12 R1
    12/2 = 6  R0
    6/2 = 3   R0
    3/2 = 1   R1
    1/2 = 0   R1
    101 = 1100101

The fraction : 1011-0000-0000-0000-0000-0000 


So the full number is :

    1 1100101 1011-0000-0000-0000-0000-0000 

Upvotes: 2

Views: 1813

Answers (1)

Stephen Canon
Stephen Canon

Reputation: 106117

Close.

The significand field is normalized in the form 1.xxx... (so far as the exponent range allows), so the significand is 1.011, and the exponent is -102.

The sign field is the sign of the number, not the sign of the exponent, so the sign is zero. The exponent is encoded by adding a bias of 127; so the biased exponent that actually gets encoded is

-102 + 127 = 25
           = b00011001

The last detail is that, because the leading bit of the significand field is known to be one, it is omitted from the encoded float, allowing one additional digit of precision. Thus, the encoded number is:

0 00011001 01100000000000000000000
s exponent       significand

or, in hex, 0x0cb00000.

Upvotes: 3

Related Questions