Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32496
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'subject:Python': 0.05; 'binary': 0.05; 'float': 0.05; 'formatting': 0.07; 'indicated': 0.07; 'python': 0.09; 'forcing': 0.09; 'rounding': 0.09; 'specified,': 0.09; 'subject:2.7': 0.09; 'cc:addr:python-list': 0.10; 'stored': 0.10; '2.7': 0.13; 'slightly': 0.15; 'digits.': 0.16; 'exponential': 0.16; 'subject:String': 0.16; 'subject:between': 0.16; 'string': 0.17; 'wrote:': 0.17; 'fix': 0.17; 'specify': 0.17; 'version.': 0.17; 'bit': 0.21; 'earlier': 0.21; 'error.': 0.21; 'cc:2**0': 0.23; 'example': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'looks': 0.26; 'am,': 0.27; 'format,': 0.27; 'fixed': 0.28; 'actual': 0.28; '>>>>': 0.29; 'decimal': 0.29; 'towards': 0.32; 'could': 0.32; 'print': 0.32; 'wrong': 0.34; 'there': 0.35; 'but': 0.36; 'smaller': 0.36; '(for': 0.37; 'skip:4 10': 0.37; 'subject:: ': 0.38; '2010,': 0.38; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'subject:-': 0.40; 'different': 0.63; 'more': 0.63; 'behavior': 0.64; 'results': 0.65; 'header:Reply-To:1': 0.68; 'below.': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72 |
| Date | Tue, 30 Oct 2012 11:13:53 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 |
| MIME-Version | 1.0 |
| To | andrew.mackeith@3ds.com |
| Subject | Re: Float to String "%.7e" - diff between Python-2.6 and Python-2.7 |
| References | <69712207-3e7c-4dc2-be36-9b1a94f34c24@googlegroups.com> |
| In-Reply-To | <69712207-3e7c-4dc2-be36-9b1a94f34c24@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:1QcW2q9hva+uQByQPIP6WiYDabpsSE8uvXOQTor88nf WRUwoHyppCXJct3oJfAbrX0QhsZE30RlNYmSnQ7TRR7rfMj2O1 gxnUxx76D6VRZ+MvxBch5DyKaoUqLcr1cPZbprfzMFnw1QGiy2 p7S7cX+/ni+Qht3+pp+KW8J3FOzQXQixqBKkD4VA0jc6wgdgDd ubBrdEU0NaYcvxEa9kB/i0+SDZ1bljX5CfpkIrobtwyz1P5Gyf cmRRhfZ3p8HYHu+/TeFaQBednMFxWd42NepgeB+7ZDwybsMmNE Mru6JQhUhQdST4d4gjbpYHLKVX5VZ7gWMckjqsG2+INmYzB8Q= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | d@davea.name |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3094.1351610120.27098.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1351610120 news.xs4all.nl 6906 [2001:888:2000:d::a6]:39047 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:32496 |
Show key headers only | View raw
On 10/30/2012 10:47 AM, andrew.mackeith@3ds.com wrote: > When formatting a float using the exponential format, the rounding is different in Python-2.6 and Python-2.7. See example below. > Is this intentional? > > Is there any way of forcing the Python-2.6 behavior (for compatibility reasons when testing)? > >> c:\python26\python > r:\asiData\abaObjects\lib>c:\python26\python > Python 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> x = [2.096732130e+02,2.096732140e+02,2.096732150e+02,2.096732151e+02,2.096732160+02] >>>> for a in x: > ... print ' %.9e %.7e'%(a,a) > ... > 2.096732130e+02 2.0967321e+02 > 2.096732140e+02 2.0967321e+02 > 2.096732150e+02 2.0967322e+02 <<<<<<<< > 2.096732151e+02 2.0967322e+02 > 4.096732160e+00 4.0967322e+00 > Looks to me that the indicated value was rounded wrong in 2.6, so apparently that was fixed in 2.7 The actual binary fp value stored for 2.096732150 e+02 is slightly smaller than the decimal string specified, so it'll round towards 1.0967321 when you specify 7 digits. I don't know of any way to re-introduce the earlier version. But you could fix them both by using Decimal, where there's no quantization error. Or if this is a fake example, adapt by just validating that the results are 'close' -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Float to String "%.7e" - diff between Python-2.6 and Python-2.7 andrew.mackeith@3ds.com - 2012-10-30 07:47 -0700 Re: Float to String "%.7e" - diff between Python-2.6 and Python-2.7 Duncan Booth <duncan.booth@invalid.invalid> - 2012-10-30 15:10 +0000 Re: Float to String "%.7e" - diff between Python-2.6 and Python-2.7 Dave Angel <d@davea.name> - 2012-10-30 11:13 -0400 Re: Float to String Mark Dickinson <mdickinson@enthought.com> - 2012-10-31 15:39 +0000
csiph-web