From: sandell@epunix.susx.ac.uk (Greg Sandell)
Subject: "byte sex" or "endian" conversion program
Date: Sat, 2 Oct 1993 21:25:47 GMT [thread overview]
Message-ID: <1993Oct2.212547.17237@syma.sussex.ac.uk> (raw)
I work across several platforms including one DEC and several non-DEC
machines. The DEC represents binary differently than all the others.
(I suppose this isn't news to many people who read this bboard!) I've
been told that the difference between standards is merely a swapping of
the upper and lower signficant portions of the value. However, when
I've tried my own conversion programs (reading in a binary value then
writing it out swapped) they don't work. There must be something I
don't know.
For example, if I had a loop to read in binary floats:
char data[4], out[4];
while (read(0,data,4) != 0) {
...I had thought that doing the following was the right thing:
out[0] = data[2] ; out[1] = data[3];
out[2] = data[0]; out[3] = data[1]
write(1,out,4);
If this is wrong, can someone show me the right way?
Thanks in advance. Email replies appreciated, as I don't typically read
this bboard.
Greg
--
Gregory J. Sandell (sandell@epunix.sussex.ac.uk)
Experimental Psychology, University of Sussex
Brighton BN1 9QG England +44-273-678058
next reply other threads:[~1993-10-02 21:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-10-02 21:25 Greg Sandell [this message]
1993-10-03 14:56 ` "byte sex" or "endian" conversion program Charles M Richmond
1993-10-04 4:33 ` Thad P Floryan
1993-10-04 16:24 ` Steve Lionel
1993-10-08 20:33 ` Kevin Ferguson
1993-10-09 1:49 ` fairfield
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox