delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/07/29/07:34:27

From: combee AT cambridge DOT scr DOT slb DOT com (Leendert Combee)
Subject: help with reading floats from file
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Date: Fri, 29 Jul 1994 10:04:23 +0100 (BST)

  Hello, 

  I have trouble reading binary floating point data (4bytes/value) from a
  file generated on a sun/unix into my code compiled with djgpp.

  If I compile and run my code on my sun as well, I have no problem: the
  code I use is

  float data[...] ;
  File *file      ;

  ....

  fread(data,sizeof(float),ns,file) ;

  It doesn't seem to matter whether I open the file as "r" or "rb", whether
  I compile with cc or gcc, it all works. If I now compile the same source 
  with djgpp on my pc, the values that are read from the same file are not
  read as proper floats (sizeof(float) is still 4bytes). Do I need to swap
  some bytes, has anyone encountered this and knows what the proper format 
  conversion is between floats in djgpp and floats under unix?

  Many thanks, Leendert.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019