update copyright file for recent contributions
[musl] / src / math / ilogbl.c
1 #include <limits.h>
2 #include "libm.h"
3
4 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
5 int ilogbl(long double x)
6 {
7         return ilogb(x);
8 }
9 #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
10 int ilogbl(long double x)
11 {
12         union ldshape u = {x};
13         uint64_t m = u.bits.m;
14         int e = u.bits.exp;
15
16         if (!e) {
17                 if (m == 0)
18                         return FP_ILOGB0;
19                 /* subnormal x */
20                 for (e = -0x3fff+1; m < (uint64_t)1<<63; e--, m<<=1);
21                 return e;
22         }
23         if (e == 0x7fff)
24                 /* in ld80 msb is set in inf */
25                 return m & (uint64_t)-1>>1 ? FP_ILOGBNAN : INT_MAX;
26         return e - 0x3fff;
27 }
28 #endif