马蓉有多少财产:查看float类型在内存中的表示方式(IEEE)

来源:百度文库 编辑:中财网 时间:2024/05/06 01:00:10

#include
#include
//#include
void printFloat();
//void printDouble();
int main()
{
    printFloat();         
    system("pause");
}

void printFloat()
{
     float f;
     printf("please input a float: \n");           //input a float
     scanf("%f", &f);                             
     int* p = (int*)&f;                            //(int*) p point to a float addr
     printf("In Memory f is: %x", *p);             //print the float using int type(hex)
         
}