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)
17static 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 <libm-alias-ldouble.h>
29
30_Float128
31__logbl (_Float128 x)
32{
33 int64_t lx, hx, ex;
34
35 GET_LDOUBLE_WORDS64 (hx, lx, x);
36 hx &= 0x7fffffffffffffffLL; /* high |x| */
37 if ((hx | lx) == 0)
38 return -1.0 / fabsl (x);
39 if (hx >= 0x7fff000000000000LL)
40 return x * x;
41 if ((ex = hx >> 48) == 0) /* IEEE 754 logb */
42 {
43 /* POSIX specifies that denormal number is treated as
44 though it were normalized. */
45 int ma;
46 if (hx == 0)
47 ma = __builtin_clzll (lx) + 64;
48 else
49 ma = __builtin_clzll (hx);
50 ex -= ma - 16;
51 }
52 return (_Float128) (ex - 16383);
53}
54
55libm_alias_ldouble (__logb, logb)
56