33,311
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main()
{
float f=123.25;
long l=*(long*)&f; // 把f所在的存储区域以long解读,并将其值赋给l
printf("float f is %f; when f's binary representation is interpreted as"
" a long integer, the value is %ld;"
" and when the long again is interpreted as a float, we got %f;\n\n"
"You will notice both floats are the same as expected!\n",
f, l, *(float*)&l);
return 0;
}