[issue7094] Add alternate float formatting styles to new-style formatting.

Mark Dickinson report at bugs.python.org
Sun Nov 21 20:31:45 CET 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

I think the change below is sufficient if we decide that the '#g' formatting should always have the given number of significant digits.

--- Lib/decimal.py      (revision 86635)
+++ Lib/decimal.py      (working copy)
@@ -3701,7 +3701,8 @@
                 self = self._round(precision+1, rounding)
             elif spec['type'] in 'fF%':
                 self = self._rescale(-precision, rounding)
-            elif spec['type'] in 'gG' and len(self._int) > precision:
+            elif spec['type'] in 'gG' and (len(self._int) > precision or
+                                           spec['alt']):
                 self = self._round(precision, rounding)
         # special case: zeros with a positive exponent can't be
         # represented in fixed point; rescale them to 0e0.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7094>
_______________________________________


More information about the Python-bugs-list mailing list