//对于float在IEE754中存储方式
float a = 5.5;
//二进制 101.1
//(-1)*0 * 1.011 * 2^2
//(-1)*S * M * 2^E
//S占一位,E占8位(要加上127),M占23位(小数点后的二进制数) 对于float 32位
// S=0,M=1.011,E=2
//E=E+127
//E 10000001
//存储在内存中
//0 10000001 01100000000000000000000
//0100 0000 1011 0000 0000 0000 0000 0000
//4 0 b 0 0 0 0 0
//40 b0 00 00
return 0;
//取出时
//1.E不全为0和1
//怎么存的怎么取
//2.E全为0
//0 00000000 01100000000000000000000
//= + - 0.011*2^-126
//3.E全为1
//0 11111111 01100000000000000000000
//= + - 1.011*2^128
//表示一个正负无穷大的数字
来个例题
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
int n = 9;
//0000 0000 0000 0000 0000 0000 0000 1001//补码
//对于*p来说
//0 00000000 00000000000000000001001
//E全为0
//(-1)^0 * 0.00000000000000000001001 * 2 ^-126 无限接近0
//将n的地址强制转换成float*类型给 *p
float* p = (float*)&n;
printf("n=%d \n", n); //9
printf("*p=%f \n", *p);//0.000000
*p = 9.0;
//(-1)^0 * 1.001 * 2^3
// 0 3+127 001
//0 10000010 00100000000000000000000
//对于n来说
//0100 0000 1000 1000 0000 0000 0000 0000 补码(原码)
//1091567616
printf("n=%d \n", n);
printf("*p=%f \n", *p);//9.0
return 0;
}