views:

55

answers:

2

hi, can anyone show how to correctly convert binary represented data into double value in C. for example, i have 8 unsigned char values to be converted to double value (let's name it buffer). so buffer[0]'s 0's bit is LSB, and buffer[7]'s 7's bit is MSB. thanks a lot in advance!

+1  A: 

Just cast it, I think

char buf[8];
double x;
...
x = *((double*) buf);
Tom Sirgedas
This technique assumes much—same architecture, format, endianness, proper object size—which are okay if the data came from the same machine.
wallyk
+2  A: 
Nicholas Knight