BYTE double相互转换

byte数组与double类型转换:

强转:

注意区分big-endian,还是little-endian
以下是little-endian的情况:

int8_t aa[8] = {(int8_t)0xd0, (int8_t)0xd0, (int8_t)0xe4, (int8_t)0x07, (int8_t)0x53, (int8_t)0x39, (int8_t)0x92, 0x3f};
double df = *(double *)aa;
或者使用:memcpy(&df, aa, sizeof(aa));
		
int8_t aa[8];
double df;
memcpy(aa, &df, sizeof(double));

你可能感兴趣的:(编程)