.
[glibc/history.git] / sysdeps / ieee754 / ldbl-128 / s_frexpl.c
blob6dbb60ece036ddf320b5c7d4b012aae92c219d5e
1 /* s_frexpl.c -- long double version of s_frexp.c.
2 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
3 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid[] = "$NetBSD: $";
18 #endif
21 * for non-zero x
22 * x = frexpl(arg,&exp);
23 * return a long double fp quantity x such that 0.5 <= |x| <1.0
24 * and the corresponding binary exponent "exp". That is
25 * arg = x*2^exp.
26 * If arg is inf, 0.0, or NaN, then frexpl(arg,&exp) returns arg
27 * with *exp=0.
30 #include "math.h"
31 #include "math_private.h"
33 #ifdef __STDC__
34 static const long double
35 #else
36 static long double
37 #endif
38 two114 = 2.0769187434139310514121985316880384E+34L; /* 0x4071000000000000, 0 */
40 #ifdef __STDC__
41 long double __frexpl(long double x, int *eptr)
42 #else
43 long double __frexpl(x, eptr)
44 long double x; int *eptr;
45 #endif
47 u_int64_t hx, lx, ix;
48 GET_LDOUBLE_WORDS64(hx,lx,x);
49 ix = 0x7fffffffffffffffULL&hx;
50 *eptr = 0;
51 if(ix>=0x7fff000000000000ULL||((ix|lx)==0)) return x; /* 0,inf,nan */
52 if (ix<0x0001000000000000ULL) { /* subnormal */
53 x *= two114;
54 GET_LDOUBLE_MSW64(hx,x);
55 ix = hx&0x7fffffffffffffffULL;
56 *eptr = -114;
58 *eptr += (ix>>48)-16382;
59 hx = (hx&0x8000ffffffffffffULL) | 0x3ffe000000000000ULL;
60 SET_LDOUBLE_MSW64(x,hx);
61 return x;
63 weak_alias (__frexpl, frexpl)