Try this:
double a;
memcpy(&a, ptr, sizeof(double));
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
or
int main()
{
unsigned char id[] = {1,2,3,4,5,6,7,8};
long long res = 0;
for (int b = 0; b < 8; ++b)
res |= ((long long)id[b]) << (b * 8);
unsigned char *ares = (unsigned char*)&res;
for (int i = 0; i < 8; ++i)
printf("%02x ", ares[i]);
return 0;
}
or
In C++:
double x;
char buf[sizeof(double)]; // your data
#include <algorithm>
// ...
std::copy(buf, buf + sizeof(double), reinterpret_cast<char*>(&x));
In C:
#include <string.h>
/* ... */
memcpy(&x, buf, sizeof(double));
In C++11, you can also use std::begin(buf) and std::end(buf) as the boundaries (include the header ), and in both languages you can use sizeof(buf) / sizeof(buf[0]) (or simply sizeof(buf)) for the size, all provided buf is actually an array and not just a pointer.