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: chu@gt40.uucp (Eugene Y C Chu) Subject: Re: DEC Unix 4.0 IEEE floating point on Alpha Date: 1997/08/05 Message-ID: <5s85v9$n7j$1@asterisk.Jpl.Nasa.Gov>#1/1 X-Deja-AN: 262566263 References: <5r5qt6$gd8@crcnis3.unl.edu> Organization: Radar Science and Engineering, Jet Propulsion Laboratory Reply-To: nospam.uucp Newsgroups: comp.sys.dec In article , Jim Griffin 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... >|<