1 /* s_logbl.c -- long double version of s_logb.c.
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
12 * ====================================================
16 * long double logbl(x)
17 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
22 #include <math_private.h>
23 #include <math_ldbl_opt.h>
24 #include <fix-int-fp-convert-zero.h>
27 __logbl (long double x
)
32 ldbl_unpack (x
, &xhi
, &xlo
);
33 EXTRACT_WORDS64 (hx
, xhi
);
35 hx
&= 0x7fffffffffffffffLL
; /* high |x| */
37 return -1.0 / fabs (x
);
38 if (hx
>= 0x7ff0000000000000LL
)
40 if (__glibc_unlikely ((rhx
= hx
>> 52) == 0))
42 /* POSIX specifies that denormal number is treated as
43 though it were normalized. */
44 rhx
-= __builtin_clzll (hx
) - 12;
46 else if ((hx
& 0x000fffffffffffffLL
) == 0)
48 /* If the high part is a power of 2, and the low part is nonzero
49 with the opposite sign, the low part affects the
52 EXTRACT_WORDS64 (lx
, xlo
);
53 if ((hxs
^ lx
) < 0 && (lx
& 0x7fffffffffffffffLL
) != 0)
56 if (FIX_INT_FP_CONVERT_ZERO
&& rhx
== 1023)
58 return (long double) (rhx
- 1023);
61 long_double_symbol (libm
, __logbl
, logbl
);