Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39454
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; '21,': 0.07; 'function,': 0.07; 'lines.': 0.07; 'wrapper': 0.07; 'python': 0.09; 'separately': 0.09; '2.7.3': 0.16; 'doubles.': 0.16; 'subtlety': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'thu,': 0.17; 'windows': 0.19; 'feb': 0.19; 'sort': 0.21; '(on': 0.22; 'subject:problem': 0.22; 'header:In-Reply-To:1': 0.25; 'implemented': 0.27; 'library.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; 'probably': 0.29; "i'm": 0.29; 'code': 0.31; 'mac': 0.32; 'received:209.85.160.46': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'built-in': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'between': 0.63; 'different': 0.63; 'box,': 0.69; 'hand': 0.82; '2013': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=FF9LPznKWjOvi8/4VfgYT12fjAC1xyLYouHD1Ik3DY0=; b=PHSWfVFrPZoPe7Kp/Q7hR9MwN7bAotvzGf0G0Nc4kAenDbKfyjY2E30icCnxQn82rU UJ3gOb+JpTBhiGWjPTuc53vNlVRjDnWGAqtoluZZICdnNCFOXP2ZLlW2HnCUB/B6B8Wf dt9jJxsFiPxgGoby+GTg/jz9M70s8wavww4Xi58TCk+Oqg0q8Qp1OMxIJzrAntGKdPDS CEEomfsf5HOHP1I4BnFs4Dhs+Q4MbSfgdvDmi20wYBXBcTXcmxjv8HqbWQtRc1BckIZT ctTG5kMi1MhPnDmWcuakCQ08Em0Nv+N3OIrRjSxjOGsayS5PawJh0Jx3TOelEnKZU162 wFBg== |
| X-Received | by 10.68.232.38 with SMTP id tl6mr56730633pbc.153.1361479409376; Thu, 21 Feb 2013 12:43:29 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <kg5sog$lfb$1@dont-email.me> |
| References | <kg5sog$lfb$1@dont-email.me> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Thu, 21 Feb 2013 13:42:49 -0700 |
| Subject | Re: Confusing math problem |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| 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.2192.1361479419.2939.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361479419 news.xs4all.nl 6968 [2001:888:2000:d::a6]:45074 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39454 |
Show key headers only | View raw
On Thu, Feb 21, 2013 at 12:33 PM, Schizoid Man <schiz_man@21stcentury.com> wrote: > Hi there, > > I run the following code in Python 3.3.0 (on a Windows 7 machine) and Python > 2.7.3 on a Mac and I get two different results: > > result1 = [] > result2 = [] > for a in range(2,101): > for b in range(2,101): > result1.append(math.pow(a,b)) > result2.append(a**b) > result1 = list(set(result1)) > result2 = list(set(result2)) > print (len(result1)) > print (len(result2)) > > On the Windows box, I get 9183 for on both lines. However, on the Mac I get > 9220 and 9183. Why this difference? Is there some sort of precision subtlety > I'm missing between ** and math.pow()? math.pow is basically a wrapper for the C standard pow function, which operates on doubles. The difference you're seeing is probably a difference in implementation in the platform's C library. The ** operator on the other hand is implemented separately as a Python built-in and operates on any numeric data type.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 19:33 +0000
Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 15:25 -0500
Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 22:39 +0000
Re: Confusing math problem Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-21 22:53 +0000
Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 23:41 +0000
Re: Confusing math problem Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-02-22 00:04 +0000
Re: Confusing math problem Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-21 17:19 -0700
Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 23:39 +0000
Re: Confusing math problem Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-21 13:42 -0700
Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 07:46 +1100
Re: Confusing math problem "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-21 22:44 +0000
Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 11:29 +1100
Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 21:19 -0500
Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 15:49 -0500
Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 08:23 +1100
Re: Confusing math problem Peter Pearson <ppearson@nowhere.invalid> - 2013-02-21 21:59 +0000
Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 09:11 +1100
Re: Confusing math problem Dave Angel <davea@davea.name> - 2013-02-21 17:33 -0500
Re: Confusing math problem Chris Angelico <rosuav@gmail.com> - 2013-02-22 10:15 +1100
Re: Confusing math problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-22 09:16 +0000
Re: Confusing math problem Serhiy Storchaka <storchaka@gmail.com> - 2013-02-22 13:48 +0200
Re: Confusing math problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-22 09:27 +0000
csiph-web