]> granicus.if.org Git - python/commit
Improve Underflow handling in the correct-rounding loop. The case for
authorStefan Krah <skrah@bytereef.org>
Thu, 31 May 2012 18:01:05 +0000 (20:01 +0200)
committerStefan Krah <skrah@bytereef.org>
Thu, 31 May 2012 18:01:05 +0000 (20:01 +0200)
commit4d3e0a695aec69b6c3f6638a65bd7469cd4fd568
tree6ec0be80830470b2a510ab8434f856a26219d50a
parentd3487be8768bc763cdd931e0de73e2e7d3d3e0a0
Improve Underflow handling in the correct-rounding loop. The case for
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.
Modules/_decimal/libmpdec/mpdecimal.c