Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

cpython: 1) Fix signature of mpd qpow uint(): contrary to the comment base is constant.

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Jun 12, 2012, 12:06 PM

Post #1 of 1 (74 views)
Permalink
cpython: 1) Fix signature of mpd qpow uint(): contrary to the comment base is constant.

http://hg.python.org/cpython/rev/8f88718fe2c4
changeset: 77412:8f88718fe2c4
user: Stefan Krah <skrah [at] bytereef>
date: Tue Jun 12 21:06:06 2012 +0200
summary:
1) Fix signature of _mpd_qpow_uint(): contrary to the comment base is constant.

2) Abort the loop for all specials, not only infinity.

3) Make the function more general and distinguish between zero clamping
and folding down the exponent. The latter case is currently handled
by setting context->clamp to 0 before calling the function.

files:
Modules/_decimal/libmpdec/mpdecimal.c | 16 ++++++++------
1 files changed, 9 insertions(+), 7 deletions(-)


diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -107,8 +107,9 @@
const mpd_context_t *ctx, uint32_t *status);
static void _mpd_base_ndivmod(mpd_t *q, mpd_t *r, const mpd_t *a,
const mpd_t *b, uint32_t *status);
-static inline void _mpd_qpow_uint(mpd_t *result, mpd_t *base, mpd_uint_t exp,
- uint8_t resultsign, const mpd_context_t *ctx, uint32_t *status);
+static inline void _mpd_qpow_uint(mpd_t *result, const mpd_t *base,
+ mpd_uint_t exp, uint8_t resultsign,
+ const mpd_context_t *ctx, uint32_t *status);

mpd_uint_t mpd_qsshiftr(mpd_t *result, const mpd_t *a, mpd_ssize_t n);

@@ -5841,12 +5842,12 @@
}

/*
- * Internal function: Integer power with mpd_uint_t exponent, base is modified!
- * Function can fail with MPD_Malloc_error.
+ * Internal function: Integer power with mpd_uint_t exponent. The function
+ * can fail with MPD_Malloc_error.
*/
static inline void
-_mpd_qpow_uint(mpd_t *result, mpd_t *base, mpd_uint_t exp, uint8_t resultsign,
- const mpd_context_t *ctx, uint32_t *status)
+_mpd_qpow_uint(mpd_t *result, const mpd_t *base, mpd_uint_t exp,
+ uint8_t resultsign, const mpd_context_t *ctx, uint32_t *status)
{
uint32_t workstatus = 0;
mpd_uint_t n;
@@ -5866,7 +5867,8 @@
if (exp & n) {
mpd_qmul(result, result, base, ctx, &workstatus);
}
- if (workstatus & (MPD_Overflow|MPD_Clamped)) {
+ if (mpd_isspecial(result) ||
+ (mpd_iszerocoeff(result) && (workstatus & MPD_Clamped))) {
break;
}
}

--
Repository URL: http://hg.python.org/cpython

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.