[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 10 bytes real

"Karl Schultz" <kschultz@researchsystems.com> wrote:
> Also, the 80x87 math processors on wintel machines are 80-bit anyway
> and I think that there are instructions that would load 80-bit floats
> into the floating point regs.  After you've done that, you can read
> them back out as a double.  I don't know if there is any C compiler
> support.

Apparently the MS visual C compiler knows about "long doubles" - 80-bit
IEEE floating point numbers.
*Provided* that your 10-byte numbers are indeed IEEE FP format, you
should be able to use the following routine (compiled etc) to do the
conversion.   On the input side I gues you'd just use a BYTARR or
something, stuffed with the inscrutable 10-byte reals, and for the
output you'd present a DOUBLE array of the right size - hopefully it
will get filled with something useful :-)
I haven't tested the routine below.   (In fact I've never used a "long
double" before.)   But give it a try.
If you don't have a MS visual C compiler, let me know and I will
compile the routine for you.

Peter Mason

	10-byte to 8-byte IEEE floating-point converter (untested).
	Peter Mason, CSIRO DEM, October 2000
#define STRICT
#include <windows.h>

BOOL WINAPI DllMain(HINSTANCE hinst, unsigned long reason, void *resvd)
	hinst=hinst;  reason=reason;  resvd=resvd;
	return 1;
  This is it.
  The call is:
  . in10[n] is an array of 10-byte IEEE floating-point numbers;
  . out8[n] is an array that will be filled with the conversions;
  . n is the number of numbers (in all its splendour?)
int WINAPI idlfp10to8(int ac, int *a[])
	register long double	*in10;
	register double		*out8;
	register int		n;
	if(ac!=3) return 1;	//incorrect number of arguments
	in10 = (long double *)a[0];
	out8 = (double *)a[1];
	n = *a[2];
	for( ; n; --n, ++in10, ++out8) *out8 = (double)(*in10);
	return 0;

Sent via Deja.com http://www.deja.com/
Before you buy.