|
#include <stdio.h>
#include <string.h>
int main()
{
typedef union
{
unsigned char buf[sizeof(float)];
struct
{
float GIM;
};
}sys;
sys g_sys = {0};
printf("GIM = %f\n", g_sys.GIM); //GIM = 0.000000
memset(g_sys.buf, 0xFF, sizeof(g_sys));
printf("g_sys.buf = %d\n", g_sys.buf[0]); //g_sys.buf = 255
printf("GIM = %f\n", g_sys.GIM);//GIM = -nan ,GIM为什么输出为-nan啊???
float b = 0xFFFFFFFF;
printf("b = %f \n", b); //b = 4294967296.000000
return 0;
}
标红的代码,为什么会输出-nan?可以详细解释下吗!谢谢!
|
|