From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,353213c6ba11774a X-Google-Attributes: gid1164f8,public From: arnold@zam331.kfa-juelich.de (A.Arnold) Subject: Re: DEC Unix 4.0 IEEE floating point on Alpha Date: 1997/07/24 Message-ID: <5r732p$9n@zam201.zam.kfa-juelich.de>#1/1 X-Deja-AN: 258479581 Distribution: world Sender: arnold@zam331 (A.Arnold) References: <5r5qt6$gd8@crcnis3.unl.edu> Organization: Forschungszentrum Juelich GmbH Keywords: ieee binary floating point alpha Reply-To: a.arnold@kfa-juelich.de Newsgroups: comp.sys.dec >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