From: thad@cup.portal.com (Thad P Floryan)
Subject: Re: "byte sex" or "endian" conversion program
Date: Sun, 3 Oct 93 21:33:46 PDT [thread overview]
Message-ID: <92299@cup.portal.com> (raw)
In-Reply-To: CEBtIw.A9B@world.std.com
In article <CEBtIw.A9B@world.std.com>
cmr@world.std.com (Charles M Richmond) writes:
| 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.
| >[...]
|
| This kind of misinformed and disgruntled muttering has finally irritated
| me to the point of sending out a small flame.
|
| First off, the writer is blaming his ignorance of big/little endian on
| DEC. The vast majority of systems in the world are byte organized in the
| same way as the DEC systems. This is demonstrably true when one considers
| that all of the IBM PC systems are in this group. Secondly, just doing a
| "man -k swap" yields the following:
| [...]
Well, your article and flame are about as useless as tits on a bird.
The original poster was having problems with floating-point byte ordering,
so let's show him the nature of the problem.
Enclosed is an extract from an article I posted a year or so ago which
illustrates the "problem" on VAX (DEC) architectures contrasted to HP, AT&T,
Amiga, Apple, SGI, and Sun systems. Though my example uses "double", the
problem with "float" is similar. Besides which, DEC doesn't use the STANDARD
IEEE floating-point representation across-the-board by default on all its
platforms (if any).
In Silicon Valley, Intel is known as "First With the Worst", so the number of
machines using Intel's (and DEC's) byte-ordering as found on IBM-PCs (and
clones thereof) is irrelevant to the current discussion (though I do
understand the original reason for "little endian" memory data/instruction
organization (cost of memory back in the 1960s and 1970s)).
Thad Floryan [ thad@btr.com, thad@cup.portal.com, thad@netcom.com ]
---------- begin enclosure
/* showres - display floating point numbers on architecture
*/
#include <stdio.h>
#include <sys/utsname.h>
typedef union {
double dbl_num;
struct {
long lw0;
long lw1;
} Ints;
} DBL;
DBL foo;
struct utsname arch;
main()
{
uname(&arch);
printf("Sys=%s, node=%s, release=%s, version=%s, machine=%s\n",
arch.sysname, arch.nodename, arch.release, arch.version, arch.machine);
foo.dbl_num = 1.0; showme();
foo.dbl_num = 10.0; showme();
foo.dbl_num = 100.0; showme();
foo.dbl_num = 1.23456789; showme();
foo.dbl_num = 12.3456789; showme();
foo.dbl_num = 123.456789; showme();
}
showme()
{
printf("\t%20.10f = %08x, %08x\n", foo.dbl_num, foo.Ints.lw0, foo.Ints.lw1);
}
Sys=HP-UX, node=fig, release=7.0, version=B, machine=9000/350
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
Sys=UNIX, node=thadlabs, release=SYSTEM5, version=3.51m, machine=mc68k
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
Sys=HP-UX, node=hpdemo1, release=A.08.07, version=A, machine=9000/705
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
Sys=HP-UX, node=flame, release=A.B7.00, version=U, machine=9000/845
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
[System is a 68020/68881 Amiga]
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de18
12.3456789000 = 4028b0fc, d324d59e
123.4567890000 = 405edd3c, 07ee0b06
Sys=A/UX, node=aux, release=2.0, version=SVR2, machine=mc68020
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
Sys=IRIX, node=iris, release=4.0.5, version=06151813, machine=IP6
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
Sys=SunOS, node=cosmic, release=4.1.1, version=1, machine=sun3
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
Sys=SunOS, node=netcom, release=4.1.2_ER, version=1, machine=sun4m
1.0000000000 = 3ff00000, 00000000
10.0000000000 = 40240000, 00000000
100.0000000000 = 40590000, 00000000
1.2345678900 = 3ff3c0ca, 4283de1b
12.3456789000 = 4028b0fc, d324d5a2
123.4567890000 = 405edd3c, 07ee0b0b
[System is VAX-780 running VMS]
1.0000000000 = 00004080, 00000000
10.0000000000 = 00004220, 00000000
100.0000000000 = 000043c8, 00000000
1.2345678900 = 0652409e, f0dc141e
12.3456789000 = 87e64245, ad139926
123.4567890000 = e9e043f6, 58583f70
---------- end enclosure
next prev parent reply other threads:[~1993-10-04 4:33 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 [this message]
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