|
|
@ -1,20 +1,20 @@ |
|
|
#include <math.h> |
|
|
#include "libm.h" |
|
|
#include <stdint.h> |
|
|
|
|
|
#include <float.h> |
|
|
|
|
|
|
|
|
|
|
|
#if LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 |
|
|
|
|
|
|
|
|
|
|
|
/* This version is for 80-bit little endian long double */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 |
|
|
long double frexpl(long double x, int *e) |
|
|
long double frexpl(long double x, int *e) |
|
|
{ |
|
|
{ |
|
|
union { long double ld; uint16_t hw[5]; } y = { x }; |
|
|
return frexp(x, e); |
|
|
int ee = y.hw[4]&0x7fff; |
|
|
} |
|
|
|
|
|
#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 |
|
|
|
|
|
long double frexpl(long double x, int *e) |
|
|
|
|
|
{ |
|
|
|
|
|
union ldshape u = {x}; |
|
|
|
|
|
int ee = u.i.se & 0x7fff; |
|
|
|
|
|
|
|
|
if (!ee) { |
|
|
if (!ee) { |
|
|
if (x) { |
|
|
if (x) { |
|
|
x = frexpl(x*0x1p64, e); |
|
|
x = frexpl(x*0x1p120, e); |
|
|
*e -= 64; |
|
|
*e -= 120; |
|
|
} else *e = 0; |
|
|
} else *e = 0; |
|
|
return x; |
|
|
return x; |
|
|
} else if (ee == 0x7fff) { |
|
|
} else if (ee == 0x7fff) { |
|
|
@ -22,16 +22,8 @@ long double frexpl(long double x, int *e) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
*e = ee - 0x3ffe; |
|
|
*e = ee - 0x3ffe; |
|
|
y.hw[4] &= 0x8000; |
|
|
u.i.se &= 0x8000; |
|
|
y.hw[4] |= 0x3ffe; |
|
|
u.i.se |= 0x3ffe; |
|
|
return y.ld; |
|
|
return u.f; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
|
long double frexpl(long double x, int *e) |
|
|
|
|
|
{ |
|
|
|
|
|
return frexp(x, e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|