#include<stdio.h>
#include<stdlib.h>
#include <process.h>
#include<math.h>
#define PI 3.1415926 //圆周率
int main()
{
// 将十六进制转换为float形式,0x
//1F 23 7D BF 00 8C 0F BB 88 FC 6B 42
unsigned char pMem[] = {0xbd ,0xa9 ,0x0c ,0xc0};
float *p = (float*)pMem;
printf("%g\r\n",*p);
int x = 0;
int y = 0;
double fitness = -(x*x-10*cos(2*PI*x)+10) - (y*y-10*cos(2*PI*y)+10) + 60;
// 将float转换为16进制
float a=2.20011;
unsigned char * b = (unsigned char*)&a;
for(int i = 0; i<4; i++)
printf("0x%2X,", b[i]);
system("pause");
return 0;
}

Apollo_tai
- 粉丝: 2
- 资源: 8