3 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4 long double remquol(long double x, long double y, int *quo)
6 return remquo(x, y, quo);
8 #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
9 long double remquol(long double x, long double y, int *quo)
11 union ldshape ux = {x}, uy = {y};
12 int ex = ux.i.se & 0x7fff;
13 int ey = uy.i.se & 0x7fff;
14 int sx = ux.i.se >> 15;
15 int sy = uy.i.se >> 15;
19 if (y == 0 || isnan(y) || ex == 0x7fff)
24 /* normalize x and y */
39 #if LDBL_MANT_DIG == 64
43 for (; ex > ey; ex--) {
49 } else if (2*mx < mx) {
66 for (; mx >> 63 == 0; mx *= 2, ex--);
68 #elif LDBL_MANT_DIG == 113
69 uint64_t hi, lo, xhi, xlo, yhi, ylo;
70 xhi = (ux.i2.hi & -1ULL>>16) | 1ULL<<48;
71 yhi = (uy.i2.hi & -1ULL>>16) | 1ULL<<48;
74 for (; ex > ey; ex--) {
80 xhi = 2*hi + (lo>>63);
84 xhi = 2*xhi + (xlo>>63);
101 for (; xhi >> 48 == 0; xhi = 2*xhi + (xlo>>63), xlo = 2*xlo, ex--);
107 /* scale result and decide between |x| and |x|-|y| */
116 if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
121 *quo = sx^sy ? -(int)q : (int)q;