Mail Archives: djgpp/2000/02/26/03:17:15
[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 -