[Python-checkins] cpython: Pad the result with zeros just before the final rounding.

stefan.krah python-checkins at python.org
Thu May 31 16:05:03 CEST 2012


http://hg.python.org/cpython/rev/dff6dd248059
changeset:   77261:dff6dd248059
parent:      77259:fc73e6ea9e73
user:        Stefan Krah <skrah at bytereef.org>
date:        Thu May 31 16:00:21 2012 +0200
summary:
  Pad the result with zeros just before the final rounding.

files:
  Modules/_decimal/libmpdec/mpdecimal.c |  4 +---
  1 files changed, 1 insertions(+), 3 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
@@ -3903,7 +3903,6 @@
     /* abs(a) <= 9 * 10**(-prec-1) */
     if (_mpd_cmp(&aa, &lim) <= 0) {
         _settriple(result, 0, 1, 0);
-        _mpd_zeropad(result, ctx, status);
         *status |= MPD_Rounded|MPD_Inexact;
         return 1;
     }
@@ -4074,8 +4073,6 @@
     }
 #endif
 
-    _mpd_zeropad(result, ctx, status);
-
     mpd_del(&tmp);
     mpd_del(&sum);
     *status |= (workctx.status&MPD_Errors);
@@ -4148,6 +4145,7 @@
             if (mpd_isspecial(result) || mpd_iszerocoeff(result) ||
                 mpd_qcmp(&t1, &t2, status) == 0) {
                 workctx.clamp = ctx->clamp;
+                _mpd_zeropad(result, ctx, status);
                 mpd_check_underflow(result, &workctx, status);
                 mpd_qfinalize(result, &workctx, status);
                 break;

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


More information about the Python-checkins mailing list