h46062
s 00035/00000/00000
d D 1.1 82/08/03 08:42:03 cecily 1 0
e
u
U
t
T
I 1
union kludge {
	double  d;
	char    byte[];
};

static double Zero      = 0.0;
static double Huge      = 7.237e75;

double
ldexp(f, exp)
union kludge f;
register int exp;
{
	register int pow2, fract;
	static union kludge mul;

	if (f.d == Zero)
		return(Zero);
	pow2 = ( ((f.byte[0]&0x7f)-0x40) << 2 ) + exp;
	fract = f.byte[1];
	do {
		pow2--;
		fract <<= 1;
	} while ((fract & 0x100) == 0);

	if (pow2 >= 0x3f * 4)
		return(f.d < 0 ? -Huge : Huge);
	if (pow2 <= -0x41 * 4)
		return(Zero);

	mul.byte[0] = (exp >> 2)  + 0x41;
	mul.byte[1] = 0x10 << (exp & 3);

	return(f.d * mul.d);
}
E 1
