From: arnold@zam331.kfa-juelich.de (A.Arnold)
Subject: Re: DEC Unix 4.0 IEEE floating point on Alpha
Date: 1997/07/24 [thread overview]
Message-ID: <5r732p$9n@zam201.zam.kfa-juelich.de> (raw)
In-Reply-To: 5r5qt6$gd8@crcnis3.unl.edu
>Can someone tell me if it's possible to get the Alpha to read/write
>IEEE in the right order? I've tried cc with the -ieee switch, but
>that didn't do anything useful, and I tried gcc, and under VMS, I
>tried cc/float=ieee ..., all of which yielded the 'backwards' IEEE format.
There's no right and no wrong, there's only little-endian and big-endian!
DEC Alpha with Digital Unix or VMS is a little-endian architecture, i.e.
for all multibyte variables, the LSB is stored at the first address. You
will see just the same on an Intel-based machine. In contrast, a big endian
architecture (what you call 'right') stores the MSB at the first memory lo-
cation. 68000, CRAY, Sparc, and PowerPC are for example big endian archi-
tectures.
From time to time, discussions break up in newsgroups about which represen-
tation is the better one. IMHO, they are just as pointless as discussions
about the better processor or OS. Both have their pros and cons, and both
work if consistently used in a single environment.
If you want to portably read and write binary data over different platforms,
you have to do the 'byte mirroring' yourself on architectures that do not
use the endianess you use in your files (I personally work on Alphas and Intels
most of the time, so my binary files are 'little endian' and I have to convert
on a big-endian machine...). For example, the following routine converts
an array of 4-byte values (doesn't matter if they are floats or ints):
void DSwap(void *Field, int Cnt)
{
register unsigned char *Run=(unsigned char *) Field,Swap;
register int z;
for (z=0; z<Cnt/4; z++,Run+=4)
{
Swap=Run[0]; Run[0]=Run[3]; Run[3]=Swap;
Swap=Run[1]; Run[1]=Run[2]; Run[2]=Swap;
}
}
Alfred Arnold
--
--------------------------------------------------------------------------------
Alfred Arnold Phone: +49 (2461) 61-2434
Zentralinstitut fuer Angewandte Mathematik Fax : +49 (2461) 61-6656
Forschungszentrum Juelich E-Mail: a.arnold@kfa-juelich.de
D-52425 Juelich, Germany http://www.kfa-juelich.de/zam/ZAMPeople/arnold.html
God is an atheist.
--------------------------------------------------------------------------------
next prev parent reply other threads:[~1997-07-24 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 ` Jim Griffin
1997-07-26 4:00 ` John Hascall
1997-08-05 4:00 ` Eugene Y C Chu
1997-07-24 4:00 ` A.Arnold [this message]
1997-07-24 4:00 ` fairfield
1997-07-25 4:00 ` Steve Lionel
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