9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] endiness and IEEE floats
@ 2004-12-23 16:45 Steve Simon
  2004-12-23 17:00 ` Nigel Roles
  2004-12-23 17:12 ` Russ Cox
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Simon @ 2004-12-23 16:45 UTC (permalink / raw)
  To: 9fans

I am reading data files, they are always little endian
(Microsoft) but they include IEEE floats. How do I read them
portably?

This is what I came up with, It assumes the endianess
of doubles is the same as vlongs, which I think is fair...

double
gf64(Biobuf *b)					// get 64 bit IEEE double
{
	uvlong n;
	double d;
	n = gi64(b);				// get 64 bit int
	memcpy(&d, &n, sizeof(n));
	return d;
}

anyone got somthing better?

-Steve


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-23 17:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-23 16:45 [9fans] endiness and IEEE floats Steve Simon
2004-12-23 17:00 ` Nigel Roles
2004-12-23 17:14   ` Russ Cox
2004-12-23 17:12 ` Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).