STM32中double类型转化为unsigned char数组

STM32中double类型转化为unsigned char数组:

double占64位,char占8位,所以一个double需要8个char存储:

double data = 3.1415926;
double temp = 0.0;
unsigned char buffer[8] = {0, 0};

memcpy(buffer, (unsigned char *)&data, 8);

temp = *(double *)&buffer;

printf("\r\n%lf\r\n", temp);
printf("\r\n%lf\r\n", *(double *)&buffer);

 

STM32中double类型转化为unsigned char数组

posted @ 2020-04-22 09:28  小大大小  阅读(2398)  评论(0编辑  收藏  举报