00001
#if !defined(__ppc__)
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
#if defined(LIBM_SCCS) && !defined(lint)
00015
static char rcsid[] =
"$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $";
00016
#endif
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#include "math.h"
00029
#include "mathP.h"
00030
00031
#ifdef __STDC__
00032
static const double
00033
#else
00034
static double
00035
#endif
00036 two54 = 1.80143985094819840000e+16;
00037
00038
#ifdef __STDC__
00039
double frexp(
double x,
int *eptr)
00040 #
else
00041 double frexp(x, eptr)
00042 double x;
int *eptr;
00043 #endif
00044 {
00045 int32_t hx, ix, lx;
00046
EXTRACT_WORDS(hx,lx,x);
00047 ix = 0x7fffffff&hx;
00048 *eptr = 0;
00049
if(ix>=0x7ff00000||((ix|lx)==0))
return x;
00050
if (ix<0x00100000) {
00051 x *=
two54;
00052
GET_HIGH_WORD(hx,x);
00053 ix = hx&0x7fffffff;
00054 *eptr = -54;
00055 }
00056 *eptr += (ix>>20)-1022;
00057 hx = (hx&0x800fffff)|0x3fe00000;
00058
SET_HIGH_WORD(x,hx);
00059
return x;
00060 }
00061
#endif