delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/26/03:17:15

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: binary to float
Date: 25 Feb 2000 23:19:56 -0800
Organization: InterWorld Communications
Lines: 41
Message-ID: <83ya88o2g3.fsf@mercury.st.hmc.edu>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000224184303 DOT 16581A-100000 AT is>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 951549723 58592 134.173.45.219 (26 Feb 2000 07:22:03 GMT)
X-Complaints-To: usenet AT nntp1 DOT interworld DOT net
NNTP-Posting-Date: 26 Feb 2000 07:22:03 GMT
User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

[Having now read the context of this article (thanks Dieter!):]

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> writes:

> On Thu, 24 Feb 2000, Dieter Buerssner wrote:
> 
> > unsigned long l;
> > float x;
> > fread(&l, sizeof l, 1, fp);
> > l = ntohl(l);
> > x = *(float *)&l;
[...]
> > Also, one other problem might arise when 
> > unsigned long is 64bit (i.e. Alpha, which uses IEEE floating point).
> 
> I don't have access to an Alpha to check.  Anybody?

On the Alpha machines to which I have access, ntohl is prototyped
like:

extern uint32_t ntohl __P ((uint32_t __netlong));

So it's really ntoh32; it does a 32 bit word on any machine.  On an
Alpha, then, you'd just need to use an appropriate 32 bit type
(unsigned int).  I checked this on both Tru64 Unix 5.0 (DEC/Compaq's
native Unix) and Redhat Linux 6.1.

Btw, the Alpha access is through Compaq's "Test Drive" program.  If
interested, visit

http://www.testdrive.compaq.com/

and register, and they'll give you free access to a variety of Alpha
(and a few Intel) machines.  They have boxes running NT, VMS, Tru64,
several flavors of Linux, and FreeBSD.  It's quite nice.


-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019