From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,4e5ff08a0f67018 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-10-04 09:55:11 PST Path: gmd.de!xlink.net!howland.reston.ans.net!pipex!uunet!decwrl!pa.dec.com!jac.nuo.dec.com!quark.enet.dec.com!lionel From: lionel@quark.enet.dec.com (Steve Lionel) Newsgroups: comp.sys.dec Subject: Re: "byte sex" or "endian" conversion program Date: 4 Oct 1993 16:24:32 GMT Organization: Digital Equipment Corporation, Nashua NH Distribution: world Message-ID: <28pio0$sgh@jac.nuo.dec.com> References: <1993Oct2.212547.17237@syma.sussex.ac.uk> Reply-To: lionel@quark.enet.dec.com (Steve Lionel) NNTP-Posting-Host: QUARK X-Newsreader: mxrn 6.18-6 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"