What is the best method to read a double from a Binary file created in C?

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))` EDIT: 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前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏