help-octave
[Top][All Lists]
Advanced

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

Big/Little Endian - Changing?


From: John W. Eaton
Subject: Big/Little Endian - Changing?
Date: Wed, 26 Mar 1997 10:24:23 -0600

On 26-Mar-1997, Kenneth Jacker <address@hidden> wrote:

| I use 'octave' to produce 16-bit binary values on one machine and use
| another machine to process those binary values.  The binary format is
| both convenient and fast.
| 
| Unfortunately, the "endianess" of the two machines is different.
| 
| Of course, I have written a small program (using the common swab()
| library function) in C to perform what some call the needed "sex change".
| 
| Question:  how can I do this solely within (e.g., without needing an
| additional program) 'octave'?  If I can find a way, this will save one
| step in my work.

Yes, Octave 2.x can swap the bytes for you when it reads the data.
Look at the documentation for the ARCH parameter for fopen, fread, and
fwrite.  For example,

  f = fopen ("foo", "r", "ieee-le");

opens the file `foo' for reading assuming the data format is little
endian with IEEE floating point, independent of the byte order of the
machine on which Octave is running.

The fread and fwrite functions also include an ARCH parameter that
allows you to override the default format specified when the file was
opened.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]