In single precision floating point format, the exponent bias is constant 127. And the particular bit pattern you gave encodes a float with 128 (1000000) as exponent:
0 10000000 11000000000000000000000
s exponent fraction
First look at the sign (s) bit, it's 0. So it's a positive number.
Then you subtract the exponent bias from the exponent, which is where 128 - 127 comes from. This gives 1
.
Then we start adding the bits in the fraction together (11000000000000000000000
):
1 + 0.5 + 0.25 + 0 + 0 + 0....
Gives 1.75
Now we have 1(sign) * 2^1(exponent) * 1.75(fraction) = 2 * 1.75 = 3.5
Another example:
00111110101010101010101010101011
Break it down:
0 01111101 01010101010101010101011
s exponent fraction
Sign is 0, so it's Positive number again.
125 (01111101) exponent, subtract exponent bias from it: 125 - 127 = -2
Decode the fraction 01010101010101010101011
1 + 0 + 0.25 + 0 + 0.0625 + 0 + 0.015625 + 0 + 0.00390625 + 0 + 0.0009765625 + 0 + 0.000244140625 + 0 + 0.00006103515625 + 0 + 0.0000152587890625 + 0 + 0.000003814697265625 + 0 + 9.5367431640625e-7 + 0 + 2.384185791015625e-7 + 1.1920928955078125e-7
This gives 1.3333333730697632
or so.
Now add it all together:
1(sign) * 2^-2(exponent) * 1.3333333730697632(fraction) = 0.25 * 1.3333333730697632 = 0.3333333432674408 =~ 0.3333333