For example: Float value is 54321.1
Bit representation on little endian machine: 1A315447
Actual Bit representation is : 4754311A
Bit representation: 01000111010101000011000100011010
Float interpretation: sign 1 bit, exponent 8 bits, fraction 23 bits.
Sign Exponent fraction
0 10001110 10101000011000100011010
Decimal
value 142 5517594/2^23
Use normal interpretation:
E = 142-(2^(8-1)-1)
(1 + 5517594/2^23)*(2^(142-(2^(8-1)-1)))
2^23 = 8388608;
142-(2^(8-1)-1) = 15;
(1 + 5517594/2^23) = 1. 6577484607696533203125
(2^(142-(2^(8-1)-1))) = 32768
(1 + 5517594/2^23)*(2^(142-(2^(8-1)-1))) = 1. 6577484607696533203125 * 32768= 54321.1015625
~54321.1
--
Happy day, happy life!
No comments:
Post a Comment