math: remove an unused variable from modfl
[musl] / src / math / modfl.c
1 #include "libm.h"
2
3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4 long double modfl(long double x, long double *iptr)
5 {
6         return modf(x, (double *)iptr);
7 }
8 #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
9 #if LDBL_MANT_DIG == 64
10 #define TOINT 0x1p63
11 #elif LDBL_MANT_DIG == 113
12 #define TOINT 0x1p112
13 #endif
14 long double modfl(long double x, long double *iptr)
15 {
16         union ldshape u = {x};
17         int e = (u.i.se & 0x7fff) - 0x3fff;
18         int s = u.i.se >> 15;
19         long double absx;
20         long double y;
21
22         /* no fractional part */
23         if (e >= LDBL_MANT_DIG-1) {
24                 *iptr = x;
25                 if (isnan(x))
26                         return x;
27                 return s ? -0.0 : 0.0;
28         }
29
30         /* no integral part*/
31         if (e < 0) {
32                 *iptr = s ? -0.0 : 0.0;
33                 return x;
34         }
35
36         /* raises spurious inexact */
37         absx = s ? -x : x;
38         y = absx + TOINT - TOINT - absx;
39         if (y == 0) {
40                 *iptr = x;
41                 return s ? -0.0 : 0.0;
42         }
43         if (y > 0)
44                 y -= 1;
45         if (s)
46                 y = -y;
47         *iptr = x + y;
48         return -y;
49 }
50 #endif