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