Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: lionel@quark.enet.dec.com (Steve Lionel)
Subject: Re: "byte sex" or "endian" conversion program
Date: 4 Oct 1993 16:24:32 GMT	[thread overview]
Message-ID: <28pio0$sgh@jac.nuo.dec.com> (raw)
In-Reply-To: 1993Oct2.212547.17237@syma.sussex.ac.uk


In article <1993Oct2.212547.17237@syma.sussex.ac.uk>, 
sandell@epunix.susx.ac.uk (Greg Sandell) writes:
|>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.
|>

There are two independent issues you need to be concerned with.  The first
is byte ordering.  Digital systems use "little-endian" byte ordering, where
(for integers), the lowest addressed byte contains the least significant
bit. Some other systems use "big-endian" ordering, where the lowest addressed
byte contains the most significant bit. 

The second is floating point representation.  Digital VAX systems use VAX
floating point, which was derived from a format used on the PDP-11 and was
in use long before the other major format, IEEE floating, was developed.

If you're dealing with converting floating-point data between a
big-endian IEEE system and VAX, you'll need to swap the byte order of
integers and do a big-endian-IEEE-to-VAX floating conversion.  If you're
using a Digital system other than VAX (DECstations or AXP systems), those
systems support IEEE floating and you need only be concerned with the 
byte ordering.  (Note that on OpenVMS AXP, IEEE floating is not the default,
but you can select it with a compiler qualifier.)

If you're using Fortran, all DEC Fortran implementations (VAX, AXP and
RISC ULTRIX) support a feature that will do the conversions for you
automatically during unformatted input or output.  See the DEC Fortran
User Manual for more information (or send me mail and I'll be glad to help.)

OpenVMS AXP also has a routine called CVT$CONVERT_FLOAT which will do the
conversions on a single data item.

-- 

Steve Lionel                           lionel@quark.enet.dec.com
SDT Languages Group
Digital Equipment Corporation
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062                       "Free advice is worth every cent"


  parent reply	other threads:[~1993-10-04 16:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-10-02 21:25 "byte sex" or "endian" conversion program Greg Sandell
1993-10-03 14:56 ` Charles M Richmond
1993-10-04  4:33   ` Thad P Floryan
1993-10-04 16:24 ` Steve Lionel [this message]
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