Converting from binary to IEEE floating-point

12,352

Solution 1

http://en.wikipedia.org/wiki/Single_precision_floating-point_format

Take the first 9 digits

0 00001101

The first one is the sign (0 == positive)

The next 8 are the exponent, converted to decimal == 13. The sign in IEEE 32 binary float are offsetted by 127, so 13 - 127 = -114.

(and the missing 1 for the fraction part, it's implicit)

Done :-)

Solution 2

for example 33.1 number

first:

convert decimal to binary

33.1 = 100001.0001100110011001100 . . .

second :

1.000010001100110011001100...*2^5

than :

Sing = positive = 0

Exponent = 5 + 127 = 132 = (1000100)

Mantissa = 000010001100110011001100...

S E M =0 1000100 000010001100110011001100 = (33.1)Decimal = (42046666)Hex

Solution 3

Let's break the representation of your number up into the component parts of an IEEE-754 floating-point value:

   0 00001101 10110011111111011010011
sign exponent significand

The exponent field is b00001101, which is 13. How do we get from there to -114?

The exponent of an IEEE-754 number is stored in a biased representation, which means that a fixed value is added to the true exponent to get the value stored in the encoding. For single (32-bit) precision, the bias is 127. To get the exponent from the encoding, we need to subtract off this bias:

13 - 127 = -114

the units bit of the significand is not stored (it is implicitly 1 unless the exponent field is zero), so we insert that bit into the significand, and get the value you listed:

b1.10110011111111011010011 * 2^-114
Share:
12,352
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I need to convert the binary number 0000 0110 1101 1001 1111 1110 1101 0011 to IEEE floating-point. The answer is 1.10110011111111011010011 x 2^−114, but how is the exponent derived?