#include<stdio.h>
//其实是对相同位序列进行不同数据类型的解释
unsigned float2unsign(float f)
{
union {
unsigned un;
float fl;
}temp_un;
temp_un.fl =f;
return temp_un.un ;
}
int main()
{
float f = 10.0;
unsigned u = float2unsign(f);
printf ("%u \n", u);
printf ("%u \n", (unsigned)f);
return 0;
}
网友评论