1#include "libm.h"
2
3#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4long double frexpl(long double x, int* e) {
5    return frexp(x, e);
6}
7#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
8long double frexpl(long double x, int* e) {
9    union ldshape u = {x};
10    int ee = u.i.se & 0x7fff;
11
12    if (!ee) {
13        if (x) {
14            x = frexpl(x * 0x1p120, e);
15            *e -= 120;
16        } else
17            *e = 0;
18        return x;
19    } else if (ee == 0x7fff) {
20        return x;
21    }
22
23    *e = ee - 0x3ffe;
24    u.i.se &= 0x8000;
25    u.i.se |= 0x3ffe;
26    return u.f;
27}
28#endif
29