更新时间:2022-04-17 14:49:23
试试这个:
double a;
memcpy(&a, ptr, sizeof(double));
其中 ptr
是指向您的字节数组的指针.如果你想避免复制使用联合,例如
where ptr
is the pointer to your byte array. If you want to avoid copying use a union, e.g.
union {
double d;
char bytes[sizeof(double)];
} u;
// Store your data in u.bytes
// Use floating point number from u.d