4 double remquo(double x, double y, int *quo)
6 union {double f; uint64_t i;} ux = {x}, uy = {y};
7 int ex = ux.i>>52 & 0x7ff;
8 int ey = uy.i>>52 & 0x7ff;
16 if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff)
21 /* normalize x and y */
23 for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1);
30 for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1);
45 for (; ex > ey; ex--) {
62 for (; uxi>>52 == 0; uxi <<= 1, ex--);
64 /* scale result and decide between |x| and |x|-|y| */
67 uxi |= (uint64_t)ex << 52;
75 if (ex == ey || (ex+1 == ey && (2*x > y || (2*x == y && q%2)))) {
80 *quo = sx^sy ? -(int)q : (int)q;