A C program spits out consecutive doubles into a binary file. I wish to read them into Python. I tried using `struct.unpack('d',f.read(8))`
I used the following in C to write a random double number
r = drand48();
fwrite((void*)&r, sizeof(double), 1, data);
The Errors are now fixed but I cannot read the first value. for an all 0.000.. number it reads it as 3.90798504668055 but the rest are fine.
It might be connected with incorrect endiness (what comes first the least significant byte or not). Show what bytes are you trying to read.
以上就是What is the best method to read a double from a Binary file created in C?的详细内容，更多请关注web前端其它相关文章！