[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Sheflug] Byte Swapping?



Hi,
    I have a problem reading a file in solaris. The file is a large
chunk of double precision binary data. In Linux, I can read the file
with a simple fread statement:
 nread = fread(raw, sizeof(double),(unsigned)rows*cols, fp) ;   
where raw is an allocated double array of size rows*cols.

    I then FTPed the file over to the solaris box (I need to link
against some libraries there), and tried the same program (exactly the
same, compiled on both boxen with gcc), and I get spurious results:
all the elements are Xe-312. They should be around 0-ish (between 5
and 5, roughly).

    I did take good care to select binary transfer, and as far as I
can remember, this takes care of the byteswapping. However, it really
does look as if the data needs some byte swapping. Is there an easy
way to transfer the data and have it conform to the UltraSparc
endianness? If not, is there a link to some code that does it :-)

    José
-- 
José L Gómez Dans			PhD student
Tel: +44 114 222 5582			Radar & Communications Group
FAX; +44 870 132 2990			Department of Electronic Engineering
					University of Sheffield UK
___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.