1*05a0b428SJohn Marino /* s_frexpf.c -- float version of s_frexp.c.
2*05a0b428SJohn Marino * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3*05a0b428SJohn Marino */
4*05a0b428SJohn Marino
5*05a0b428SJohn Marino /*
6*05a0b428SJohn Marino * ====================================================
7*05a0b428SJohn Marino * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8*05a0b428SJohn Marino *
9*05a0b428SJohn Marino * Developed at SunPro, a Sun Microsystems, Inc. business.
10*05a0b428SJohn Marino * Permission to use, copy, modify, and distribute this
11*05a0b428SJohn Marino * software is freely granted, provided that this notice
12*05a0b428SJohn Marino * is preserved.
13*05a0b428SJohn Marino * ====================================================
14*05a0b428SJohn Marino */
15*05a0b428SJohn Marino
16*05a0b428SJohn Marino #include "math.h"
17*05a0b428SJohn Marino #include "math_private.h"
18*05a0b428SJohn Marino
19*05a0b428SJohn Marino static const float
20*05a0b428SJohn Marino two25 = 3.3554432000e+07; /* 0x4c000000 */
21*05a0b428SJohn Marino
22*05a0b428SJohn Marino float
frexpf(float x,int * eptr)23*05a0b428SJohn Marino frexpf(float x, int *eptr)
24*05a0b428SJohn Marino {
25*05a0b428SJohn Marino int32_t hx,ix;
26*05a0b428SJohn Marino GET_FLOAT_WORD(hx,x);
27*05a0b428SJohn Marino ix = 0x7fffffff&hx;
28*05a0b428SJohn Marino *eptr = 0;
29*05a0b428SJohn Marino if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */
30*05a0b428SJohn Marino if (ix<0x00800000) { /* subnormal */
31*05a0b428SJohn Marino x *= two25;
32*05a0b428SJohn Marino GET_FLOAT_WORD(hx,x);
33*05a0b428SJohn Marino ix = hx&0x7fffffff;
34*05a0b428SJohn Marino *eptr = -25;
35*05a0b428SJohn Marino }
36*05a0b428SJohn Marino *eptr += (ix>>23)-126;
37*05a0b428SJohn Marino hx = (hx&0x807fffff)|0x3f000000;
38*05a0b428SJohn Marino SET_FLOAT_WORD(x,hx);
39*05a0b428SJohn Marino return x;
40*05a0b428SJohn Marino }
41