float and UINT转换问题
新手问题~怎么转回1072048784来?程序代码:
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { unsigned int B=1072048784;//3F E6 2A 90 printf("%u\n",B); float Result1=0; memcpy(&Result1, &B, sizeof(float)); printf("%f\n",Result1); printf("//----------------------------\n"); char A[]={"1.798174"}; printf("%s\n",A); int Result2=0; memcpy(&Result2, &A, strlen(A)); printf("%u\n",Result2); printf("//----------------------------\n"); float C=(float)atof(A); printf("%d\n",C);//若注解这行则下一行出的数值又会变~这是为何? printf("%u\n",C); return 0; }
1072048784
1.798174
//----------------------------
1.798174
959917617
//----------------------------
939524096
1073741824 or 939524096 //若注解上一行则出的数值会变