From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,4e5ff08a0f67018,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-10-03 00:09:44 PST Newsgroups: comp.sys.dec Path: gmd.de!xlink.net!howland.reston.ans.net!spool.mu.edu!agate!doc.ic.ac.uk!syma!epunix.susx.ac.uk!sandell From: sandell@epunix.susx.ac.uk (Greg Sandell) Subject: "byte sex" or "endian" conversion program Message-ID: <1993Oct2.212547.17237@syma.sussex.ac.uk> Sender: root@syma.sussex.ac.uk (Admin) Nntp-Posting-Host: epunix.ep.susx.ac.uk Organization: University of Sussex at Brighton X-Newsreader: TIN [version 1.2 PL0] Date: Sat, 2 Oct 1993 21:25:47 GMT 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