home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_09_08
/
9n08016a
< prev
next >
Wrap
Text File
|
1991-07-10
|
923b
|
27 lines
/* _Dunscale function -- IEEE 754 version */
#include "xmath.h"
short _Dunscale(short *pex, double *px)
{ /* separate *px to 1/2 <= |frac| < 1 and 2^*pex */
unsigned short *ps = (unsigned short *)px;
short xchar = (ps[_D0] & _DMASK) >> _DOFF;
if (xchar == _DMAX)
{ /* NaN or INF */
*pex = 0;
return (ps[_D0] & _DFRAC || ps[_D1]
|| ps[_D2] || ps[_D3] ? NAN : INF);
}
else if (0 < xchar || (xchar = _Dnorm(ps)) != 0)
{ /* finite, reduce to [1/2, 1) */
ps[_D0] = ps[_D0] & ~_DMASK | _DBIAS << _DOFF;
*pex = xchar - _DBIAS;
return (FINITE);
}
else
{ /* zero */
*pex = 0;
return (0);
}
}