summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-05-31 14:21:34 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-05-31 14:21:34 (GMT)
commit9a5beece1beda4b1e9da4e61b3bc3499c12b9e38 (patch)
tree87be58f54c35b3af1a0368141c4004a0f5314968 /Modules
parent1ef17954ccc8530a32c359029e48c79af6fb0935 (diff)
downloadcpython-9a5beece1beda4b1e9da4e61b3bc3499c12b9e38.zip
cpython-9a5beece1beda4b1e9da4e61b3bc3499c12b9e38.tar.gz
cpython-9a5beece1beda4b1e9da4e61b3bc3499c12b9e38.tar.bz2
Improve comments.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_decimal/libmpdec/mpdecimal.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
index 17fcf25..e5d3bf2 100644
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -3953,8 +3953,18 @@ _mpd_get_exp_iterations(const mpd_t *r, mpd_ssize_t p)
}
/*
- * Internal function, specials have been dealt with. The result has a
- * relative error of less than 0.5 * 10**(-ctx->prec).
+ * Internal function, specials have been dealt with. Apart from Overflow
+ * and Underflow, two cases must be considered for the error of the result:
+ *
+ * 1) abs(a) <= 9 * 10**(-prec-1) ==> result == 1
+ *
+ * Absolute error: abs(1 - e**x) < 10**(-prec)
+ * -------------------------------------------
+ *
+ * 2) abs(a) > 9 * 10**(-prec-1)
+ *
+ * Relative error: abs(result - e**x) < 0.5 * 10**(-prec) * e**x
+ * -------------------------------------------------------------
*
* The algorithm is from Hull&Abrham, Variable Precision Exponential Function,
* ACM Transactions on Mathematical Software, Vol. 12, No. 2, June 1986.
@@ -3998,9 +4008,9 @@ _mpd_qexp(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx,
*
* MAX-EMAX+1 < log10(e^(0.1*10*t)) <= log10(e^(r*10^t)) < adjexp(e^(r*10^t))+1
*
- * (2) -1 < r <= -0.1, so e^r <= e^-0.1. It t > MAX_T, underflow occurs:
+ * (2) -1 < r <= -0.1, so e^r <= e^-0.1. If t > MAX_T, underflow occurs:
*
- * adjexp(e^(r*10^t)) <= log10(e^(r*10^t)) <= log10(e^(-0.1*10^t) < MIN-ETINY
+ * adjexp(e^(r*10^t)) <= log10(e^(r*10^t)) <= log10(e^(-0.1*10^t)) < MIN-ETINY
*/
#if defined(CONFIG_64)
#define MPD_EXP_MAX_T 19