Update.
[glibc.git] / sysdeps / libm-ieee754 / s_frexpl.c
blob7a49bc37c8dde179169c78892c9c26c987276bd2
1 /* s_frexpl.c -- long double version of s_frexp.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
4 */
6 /*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid[] = "$NetBSD: $";
19 #endif
22 * for non-zero x
23 * x = frexpl(arg,&exp);
24 * return a long double fp quantity x such that 0.5 <= |x| <1.0
25 * and the corresponding binary exponent "exp". That is
26 * arg = x*2^exp.
27 * If arg is inf, 0.0, or NaN, then frexpl(arg,&exp) returns arg
28 * with *exp=0.
31 #include "math.h"
32 #include "math_private.h"
34 #ifdef __STDC__
35 static const long double
36 #else
37 static long double
38 #endif
39 #if LDBL_MANT_DIG == 64
40 two65 = 3.68934881474191032320e+19L; /* 0x4040, 0x80000000, 0x00000000 */
41 #else
42 # error "Cannot handle this MANT_DIG"
43 #endif
46 #ifdef __STDC__
47 long double __frexpl(long double x, int *eptr)
48 #else
49 long double __frexpl(x, eptr)
50 long double x; int *eptr;
51 #endif
53 u_int32_t se, hx, ix, lx;
54 GET_LDOUBLE_WORDS(se,hx,lx,x);
55 ix = 0x7fff&se;
56 *eptr = 0;
57 if(ix==0x7fff||((ix|hx|lx)==0)) return x; /* 0,inf,nan */
58 if (ix==0x0000) { /* subnormal */
59 x *= two65;
60 GET_LDOUBLE_EXP(se,x);
61 ix = se&0x7fff;
62 *eptr = -65;
64 *eptr += ix-16382;
65 se = (se & 0x8000) | 0x3ffe;
66 SET_LDOUBLE_EXP(x,se);
67 return x;
69 weak_alias (__frexpl, frexpl)