h52901
s 00031/00000/00000
d D 1.1 82/08/03 08:41:45 cecily 1 0
e
u
U
t
T
I 1
/*
 * frexp(x, ip)
 *
 * Return a fractional value with      1/16 <= |value| < 1
 * and store exponent in *ip with      x = value * 2**(*ip)
 */

union kludge {
	double  d;
	char    byte[1];
};

double
frexp(x, ip)
union kludge x;
int *ip;
{
	register int arg, exp;

	if (x.d == 0.0) {	/* Very easy if arg is zero */
		*ip = 0;
		return(x.d);
	}
	arg = exp = x.byte[0];  /* Get the exponent */
	exp &= 0x7f;            /* Remove the sign */
	exp -= 0x40;            /* Remove the bias */
	arg -= exp;             /* Set arg exponent to 0x40 or 0xc0 */
	x.byte[0] = arg;
	*ip = exp << 2;         /* Store exponent as power of 2 */
	return(x.d);            /* Return altered result */
}
E 1
