]> granicus.if.org Git - python/commitdiff
Issue #7048: logb should round its result when that result doesn't fit
authorMark Dickinson <dickinsm@gmail.com>
Wed, 7 Oct 2009 19:22:05 +0000 (19:22 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Wed, 7 Oct 2009 19:22:05 +0000 (19:22 +0000)
into the available precision.  (Tests for this change are included in
the most recent set of testcases from the Decimal Specification site;
those testcases will be updated shortly.)

Lib/decimal.py
Misc/NEWS

index 4d1f7f9f152a3495c677ea134d7db267b87f1358..75e5eea7b970312bbcbc77425317b6edf633f98a 100644 (file)
@@ -3126,7 +3126,8 @@ class Decimal(object):
         # otherwise, simply return the adjusted exponent of self, as a
         # Decimal.  Note that no attempt is made to fit the result
         # into the current context.
-        return Decimal(self.adjusted())
+        ans = Decimal(self.adjusted())
+        return ans._fix(context)
 
     def _islogical(self):
         """Return True if self is a logical operand.
index f90c8f4fa7d10ac34a3756dbacfea98781e329f8..cbd3040126e71f7ab80485dd5bd85c3dd6c34956 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -398,6 +398,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #7048: Force Decimal.logb to round its result when that result
+  is too large to fit in the current precision.
+
 - Issue #6516: Added owner/group support when creating tar archives in 
   Distutils.