1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #if defined(LIBM_SCCS) && !defined(lint)
- static char rcsid[] = "$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $";
- #endif
- #include "math.h"
- #include "math_private.h"
- #ifdef __STDC__
- static const double
- #else
- static double
- #endif
- two54 = 1.80143985094819840000e+16;
- #ifdef __STDC__
- double frexp(double x, int *eptr)
- #else
- double frexp(x, eptr)
- double x; int *eptr;
- #endif
- {
- int32_t hx, ix, lx;
- EXTRACT_WORDS(hx,lx,x);
- ix = 0x7fffffff&hx;
- *eptr = 0;
- if(ix>=0x7ff00000||((ix|lx)==0)) return x;
- if (ix<0x00100000) {
- x *= two54;
- GET_HIGH_WORD(hx,x);
- ix = hx&0x7fffffff;
- *eptr = -54;
- }
- *eptr += (ix>>20)-1022;
- hx = (hx&0x800fffff)|0x3fe00000;
- SET_HIGH_WORD(x,hx);
- return x;
- }
|