fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / mathfp / sf_frexp.c
blobc2751f65c5c8a04221fd94d906adbad1dffa1449
2 /* @(#)z_frexpf.c 1.0 98/08/13 */
3 /******************************************************************
4 * frexp
6 * Input:
7 * d - floating point value
8 * exp - exponent value
10 * Output:
11 * A floating point value in the range [0.5, 1).
13 * Description:
14 * This routine breaks a floating point value into a number f and
15 * an exponent exp such that d = f * 2 ^ exp.
17 *****************************************************************/
19 #include "fdlibm.h"
20 #include "zmath.h"
22 float frexpf (float d, int *exp)
24 float f;
25 __int32_t wf, wd;
27 GET_FLOAT_WORD (wd, d);
29 /* Get the exponent. */
30 *exp = ((wd & 0x7f800000) >> 23) - 126;
32 /* Get the mantissa. */
33 wf = wd & 0x7fffff;
34 wf |= 0x3f000000;
36 SET_FLOAT_WORD (f, wf);
38 /* Check for special values. */
39 switch (numtestf (f))
41 case NAN:
42 case INF:
43 errno = EDOM;
44 *exp = 0;
45 return (f);
48 return (f);
51 #ifdef _DOUBLE_IS_32BITS
53 double frexp (double x, int *exp)
55 return (double) frexpf ((float) x, exp);
58 #endif /* defined(_DOUBLE_IS_32BITS) */