I am testing IEEE 754 floating format with VS2008 using the example below:
int main(int argc, char *argv[])
{
float i = 0.15625;
}
I put &i to the VS2008 watch and I see the address is 0x0012FF60 and I can see address’s content is 00 00 20 3e from Memory debug window, see below:
0x0012FF60 00 00 20 3e cc cc cc cc
BTW I have the basic knowledge of IEEE754 floating format and I know IEEE 754 floating format consist of three fields: sign bit, exponent, and fraction. The fraction is the significand without its most significant bit.
But how did I calcuate exactly from little endian 00 00 20 3e to 0.15625 ?
Many thanks
You are printing out something broken. We only need 32 bits, which are:
Your variable in binary:
Logical value accounting for little endian:
According to IEEE:
So now it’s clear:
S = 0)So the value is 5/4 / 8 = 5/32 = 0.15625.