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数组