src/libm/s_scalbn.c
changeset 7678 286c42d7c5ed
parent 6044 35448a5ea044
child 11683 48bcba563d9c
equal deleted inserted replaced
7677:871d43c6968a 7678:286c42d7c5ed
    52             return x;           /* +-0 */
    52             return x;           /* +-0 */
    53         x *= two54;
    53         x *= two54;
    54         GET_HIGH_WORD(hx, x);
    54         GET_HIGH_WORD(hx, x);
    55         k = ((hx & 0x7ff00000) >> 20) - 54;
    55         k = ((hx & 0x7ff00000) >> 20) - 54;
    56         if (n < -50000)
    56         if (n < -50000)
    57             return tiny * x;    /*underflow */
    57             return tiny * x;    /* underflow */
    58     }
    58     }
    59     if (k == 0x7ff)
    59     if (k == 0x7ff)
    60         return x + x;           /* NaN or Inf */
    60         return x + x;           /* NaN or Inf */
    61     k = k + n;
    61     k = k + n;
    62     if (k > 0x7fe)
    62     if (k > 0x7fe)
    65         SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
    65         SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
    66         return x;
    66         return x;
    67     }
    67     }
    68     if (k <= -54) {
    68     if (k <= -54) {
    69         if (n > 50000)          /* in case integer overflow in n+k */
    69         if (n > 50000)          /* in case integer overflow in n+k */
    70             return huge_val * copysign(huge_val, x);    /*overflow */
    70             return huge_val * copysign(huge_val, x);    /* overflow */
    71         else
    71         else
    72             return tiny * copysign(tiny, x);    /*underflow */
    72             return tiny * copysign(tiny, x);    /* underflow */
    73     }
    73     }
    74     k += 54;                    /* subnormal result */
    74     k += 54;                    /* subnormal result */
    75     SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
    75     SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20));
    76     return x * twom54;
    76     return x * twom54;
    77 }
    77 }