From: chu@gt40.uucp (Eugene Y C Chu)
Subject: Re: DEC Unix 4.0 IEEE floating point on Alpha
Date: 1997/08/05 [thread overview]
Message-ID: <5s85v9$n7j$1@asterisk.Jpl.Nasa.Gov> (raw)
In-Reply-To: griffin-2407971002590001@ts-2-61.chatt.voyageronline.net
In article <griffin-2407971002590001@ts-2-61.chatt.voyageronline.net>,
Jim Griffin <griffin@voyageronline.net> wrote:
>In article <5r5qt6$gd8@crcnis3.unl.edu>, james@engrs.unl.edu (James Nau) wrote:
>> I've come across a problem with the floating point format on
>> DEC alphas. It happens under both VMS and Digital Unix. It
>> appears to me that Alphas store IEEE floating point numbers
>> backwards. On an Alpha, for value 511.0, I get:
>> 00 80 FF 43
>> as the binary representation [written by
>> fwrite( &x, sizeof(float), 1, outfile);]
>> while on every other Unix workstation I've been able to get my fingers
>> on yields:
>> 43 FF 80 00
>It's not the wrong order. DECs are little-endian machines, whereas most
>other Unix workstations, PCs and Macs are big-endian. Little-endian
>machines store data into memory in a different order than big-endian
>machines.
>One work-around is to use the htonl call before storing the data in a
>file, but that may not be a good solution for your application.
One additional note: the htonl, ntohl, htons, and ntohs routines are
typically coded by the native systems more efficiently than what you can
do writing even a tight loop. Also, it seems that by some sort of
agreement in the industry, the network byte order is now Bigendian, so
these conversion routines do nothing on Bigendian systems. This means
that you can include calls to these routines in your source code, and it
will be portable between the two types of machines.
Personal opinion:
I think it's more logical to store higher order bytes into higher
addressed memories, like Little Endian. When I perform mathematical
operations, I (along with everyone else I know of) work in Little
Endian; least significant digits to most significant digits from right
to left. But the od utility in UNIX displays Big Endian more clearly
(from left to right), while the VMS dump utility displays Little Endian
more clearly (from right to left).
eyc
--
>|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|< >|<
>|< Me: Eugene Chu (email to chu at gt40 in domain jpl nasa gov) >|<
>|< Related topics only...no spammers or unsolicited e-mail >|<
>|< Motto: I'm Mr. Butterfly...One's roots can be so complex... >|<
prev parent reply other threads:[~1997-08-05 4:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-07-23 4:00 DEC Unix 4.0 IEEE floating point on Alpha James Nau
1997-07-23 4:00 ` Paul DeMone
1997-07-24 4:00 ` Emmanuel Choquet
1997-07-24 4:00 ` A.Arnold
1997-07-24 4:00 ` fairfield
1997-07-25 4:00 ` Steve Lionel
1997-07-24 4:00 ` Jim Griffin
1997-07-26 4:00 ` John Hascall
1997-08-05 4:00 ` Eugene Y C Chu [this message]
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