//浮点数存储
int main()
{
int n = 9;
//00000000 00000000 00000000 00001001
//0 00000000 00000000000000000001001
//S E(8bit) M(23bit)
//E=-126
//M=0.000000000000000000001001
//+ 0.000000000000000000001001 *2^-126
float* pFloat = (float*)&n;
printf("n的值为:%d\n", n);//9
printf("*pFloat的值为:%f\n", *pFloat);//0.000000
*pFloat = 9.0;
//1001.0
//1.001*2^3
//S=0 E=3 M=1.001
//0 10000010 00100000000000000000000 //这里的E(3+127=130 8bit)
//01000001000100000000000000000000
printf("num的值为:%d\n", n);//1091567616 01000001000100000000000000000000
printf("*pFloat的值为:%f\n", *pFloat);//9.000000
return 0;
}
浮点数存储的公式