I am tryling to learn C and now i am a floats. I know all values have different sizes on different machines. But i am trying to learn the concept.
Lets say a float is saved in 4 bytes. I read that the first bit is the sign bit, which decide if the number is positve or negative. Then the next 7 bits is the exponent and the rest (23 bits) is the mantissa. Which could be this:
1 010 1001 0000 0000 1011 1001 0000 111
But how does this translate to a float? I can read binary but i dont see the formula behind it :). Could some one explain this one to me, or how it works?
I wrote this a few years ago.
I think it should help you understand how floating point numbers are represented:
http://www.eosgarden.com/en/articles/float/
Basically, the formula for normalized numbers is:
-1^S * 1.M * 2^( E - 127 )where S is the sign, M the mantissa, and E the exponent. But everything is explained in details in the previous link.