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: griffin@voyageronline.net (Jim Griffin) Subject: Re: DEC Unix 4.0 IEEE floating point on Alpha Date: 1997/07/24 Message-ID: #1/1 X-Deja-AN: 258716175 References: <5r5qt6$gd8@crcnis3.unl.edu> X-Complaints-To: news@news3.texas.net X-Trace: news3.texas.net 869753022 10000 (None) 209.42.129.61 Organization: Texas Networking, Inc. Newsgroups: comp.sys.dec In article <5r5qt6$gd8@crcnis3.unl.edu>, james@engrs.unl.edu (James Nau) wrote: > Hi all, > > 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 > > which all the tools and info I find say this is 511.0 in IEEE format. > > 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. > > [my immediate need is for reading IEEE binary format generated > elsewhere, into a canned program, without wanting to write a byte > re-ordering program...] > > Thanks for any help > > james 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. -- Jim Griffin - TNS/AANR griffin@voy.net "You can fool all of the people some of the time --- and that's sufficient.