Google
 

Monday, October 08, 2007

How to get the decimal value from the bit representation of a float value?(3)

For example: Float value is 3490593.0

Bit representation on little endian machine: 840C554A

Actual Bit representation is : 4A550C84

Bit representation: 01001010010101010000110010000100

Float interpretation: sign 1 bit, exponent 8 bits, fraction 23 bits.

         Sign    Exponent          fraction

           0     10010100     10101010000110010000100

Decimal

value              148         5573764/2^23

 

Use normal interpretation:

E = 148-(2^(8-1)-1)

(1 + 5573764/2^23)*(2^(148-(2^(8-1)-1)))

2^23 = 8388608;

148-(2^(8-1)-1) = 21;

(1 + 5573764/2^23) = 1. 664444446563720703125

(2^(148-(2^(8-1)-1))) = 2097152

 

(1 + 5573764/2^23)*(2^(148-(2^(8-1)-1))) = 1. 664444446563720703125* 2097152= 3490593



--
Happy day, happy life!

No comments: