[ale] Re: binary data format (fwd)

James W. Lynch jwl at atlanta.cray.com
Thu Mar 7 08:05:52 EST 1996


---------  Received message begins Here  ---------

> From ale-owner at cc.gatech.edu Wed Mar  6 21:25 EST 1996
> From: Unix Guru Dude <geof at denali.is.net>
> X-Gcb: -----BEGIN GEEK CODE BLOCK-----
> X-Gcb: GCS/M d-(--)>---$ s+()>++:() a C+++(++++)$ ULVHS++++$
> X-Gcb: P+(++)$>+++++ L+++(++)>+++++$ !E---(--) W++$>+++$
> X-Gcb: N++(+)>+++$ o+>++++ K-?> w---(+)$>--- O@ !M !V(--)
> X-Gcb: PS+(++)@>++ PE++(+)>+++$ Y+(++)>++$ PGP++(+)>+++$ t+()@ !5
> X-Gcb: X++>+++$ !R tv(tv)? b++(+)>++++ DI++ !D--(-) G(-)>++++$
> X-Gcb: e++>+++$ h----(--)>++$ r+++>$ y?
> X-Gcb: -----END GEEK CODE BLOCK-----
Can we have less of this please???


> 
> Thought I'd look to the ALE for some help for this guy.  If anyone knows of
> a tool that will assist him with converting this Sun data to Linux, please
> either let me know of email him at the address below.  Actually, if you are
> aware of such a tool, I'd like to know too, so if you respond to him, CC:
> me please.
> 
> }> >What is the difference between the binary formats on a Sun Sparc
> }> >and a Linux system?  I have a bunch of binary data that was written
> }> >on a Sparc, but I can't get anything but gibberish when I try
> }> >to read it on my Linux system.  How can I convert the data to
> }> >be read by the Linux system?
> }> 
> }> It may be the representation of the actual data, referred to as little
> }> endian vs. big endian.  Basically every other byte is swapped.  The
> }> easiest way to check it out is to do an octal dump using 'od' on the
> }> file.  The machine will represent the data either byte0, byte1 or byte1, byte0
> }> order.   You could write a small C program to swap the bytes if you are
> }> familiar with bit twiddling.  There are probably tools out there to do
> }> it, but I've never seen them.
> }
> }Thanks for the comments.  One tool that's been suggested is htonl,
> }which might come in handy.  Otherwise I do it myself.  What you
> }mentioned raises a question:  In older versions of Unix (e.g. SunOS 4.1), 
> }od let you define the number of bytes per line with -w, but the od
> }on Solaris 2.0 doesn't support this switch.  Any suggestions?

I agree with the folks that said that it was impossible without knowing
the structure of the data.  I did a little test and found that in the
case of double floating point data, the 8 byte field is exactly reversed.
I suspect that float is the same, and maybe even int, but without knowing
the field lengths, a general algorithm would fail.  If one knew that the
file only contained double float data, it would be trivial to write 
a program to fix it.  The same for a file that consists of all the same
type of data.

Jim.
------------------------------------------------------------------------
Jim Lynch, Sales Analyst,  Cray Research, Inc. / ARS: K4GVO
Southeast District, Phone: (770) 631-2254, Email: jwl at cray.com
Suite 270, 200 Westpark Drive, Peachtree City, GA 30269






More information about the Ale mailing list