0c61cdae25ffa9e19a408fb1bfe57dd2d2760963
[platform/upstream/glibc.git] / sysdeps / ieee754 / ldbl-128ibm / s_logbl.c
1 /* s_logbl.c -- long double version of s_logb.c.
2  * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
3  */
4
5 /*
6  * ====================================================
7  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8  *
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  * ====================================================
14  */
15
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid[] = "$NetBSD: $";
18 #endif
19
20 /*
21  * long double logbl(x)
22  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
23  * Use ilogb instead.
24  */
25
26 #include "math.h"
27 #include "math_private.h"
28 #include <math_ldbl_opt.h>
29
30 #ifdef __STDC__
31         long double __logbl(long double x)
32 #else
33         long double __logbl(x)
34         long double x;
35 #endif
36 {
37         int64_t lx,hx;
38         GET_LDOUBLE_WORDS64(hx,lx,x);
39         hx &= 0x7fffffffffffffffLL;             /* high |x| */
40         if((hx|(lx&0x7fffffffffffffffLL))==0) return -1.0/fabs(x);
41         if(hx>=0x7ff0000000000000LL) return x*x;
42         if((hx>>=52)==0)                        /* IEEE 754 logb */
43                 return -1022.0;
44         else
45                 return (long double) (hx-0x3ff);
46 }
47 long_double_symbol (libm, __logbl, logbl);