• Stefan Krah's avatar
    Improve Underflow handling in the correct-rounding loop. The case for · 4d3e0a69
    Stefan Krah authored
    Underflow to zero hasn't changed: _mpd_qexp() internally uses MIN_EMIN,
    so the result would also underflow to zero for all emin > MIN_EMIN.
    
    In case digits are left, the informal argument is as follows: Underflow can
    occur only once in the last multiplication of the power stage (in the Horner
    stage Underflow provably cannot occur, and if Underflow occurred twice in
    the power stage, the result would underflow to zero on the second occasion).
    
    Since there is no double rounding during Underflow, the effective work
    precision is now 1 <= result->digits < prec. It can be shown by a somewhat
    tedious argument that abs(result - e**x) < ulp(result, result->digits).
    
    Therefore the correct rounding loop now uses ulp(result, result->digits)
    to generate the bounds for e**x in case of Underflow.
    4d3e0a69
mpdecimal.c 209 KB