Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39512
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'value,': 0.03; 'intermediate': 0.05; 'converts': 0.07; 'python': 0.09; 'finite': 0.09; 'integers': 0.09; 'size,': 0.13; 'binary,': 0.16; 'carefully.': 0.16; 'decimal.': 0.16; 'determining': 0.16; 'digits)': 0.16; 'exponent': 0.16; 'integers,': 0.16; 'precision.': 0.16; 'radix': 0.16; 'symmetric': 0.16; 'wrote:': 0.17; 'differ': 0.17; 'integer': 0.17; 'discussion': 0.20; 'trying': 0.21; 'subject:problem': 0.22; 'machine': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'plain': 0.27; "doesn't": 0.28; 'represent': 0.28; 'comparison': 0.29; 'decimal': 0.29; 'received:192.168.1.3': 0.29; 'sets.': 0.29; 'no,': 0.29; "i'm": 0.29; 'usually': 0.30; 'unlike': 0.30; 'suggestion': 0.32; 'point,': 0.33; 'programming,': 0.33; 'to:addr:python-list': 0.33; 'whatever': 0.35; 'compared': 0.35; 'feed': 0.35; 'doing': 0.35; 'pm,': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'compare': 0.36; "i'll": 0.36; 'two': 0.37; 'rather': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'short': 0.39; 'little': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'matter': 0.61; 'mentioned': 0.63; 'different': 0.63; 'our': 0.65; 'offer': 0.65; 'frequently': 0.65; 'lose': 0.71; 'received:74.208': 0.71; 'hand': 0.82; 'algorithm,': 0.84; 'blob': 0.84; 'interesting,': 0.84; 'off,': 0.84 |
| Date | Thu, 21 Feb 2013 21:19:15 -0500 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Confusing math problem |
| References | <kg5sog$lfb$1@dont-email.me> <mailman.2193.1361479569.2939.python-list@python.org> <kg67ul$d4v$1@dont-email.me> |
| In-Reply-To | <kg67ul$d4v$1@dont-email.me> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:WYDQTcLM9xNFzwmtylsj9bBDt5GSw0MaWdVX2Tr7MsU 2QdedG11E7d4x+Px7ciIqVSAWVBkBS+tk1T2ZP6HnJVxEWP/OO FPp8Ch6+aej06g5kAYQr68wv+Cc+imB5vo9necr9C0qCpbgnyp f2d7ZcerCkzCeLn25sNaFbcCTZ7FJvjQ/VZxixp6kH7euhwfrm l05VK9UNWMsrLEcLGNUav8bwRJshJGZ2dN4rtolAI8Gk2nchLy bXnyIznbD4zT2ZqevyQlfH3IXrthBVq0XB27MbuVSJczJ8L/mP o/wYnJ3QOQDSw53HQK1VCK0BagpZUOlcYty4C3Q2EzIY09LHHX n82MIDOqV6OYYfBja5pc= |
| 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.2233.1361499562.2939.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361499562 news.xs4all.nl 6844 [2001:888:2000:d::a6]:46907 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39512 |
Show key headers only | View raw
On 02/21/2013 05:44 PM, Schizoid Man wrote: > <snip> > > > No, I was aware to be honest. I thought ** was just short hand for > math.pow(). Since ** is the integer operation It's an integer operation because you started with two ints. Unlike math.pow, which converts to floats, whatever you feed it. > > I compared the difference and got a large blob of numbers. To make a > proper comparison I'll need to compare the base and exponent for which > the numbers are different rather than the numbers themselves. I'm > following Dave's suggestion of determining the symmetric difference of > the sets. But once you have a few that are just plain way off, it doesn't really matter whether some others differ in the 17th place. All the other discussion is interesting, but don't forget the main point, that trying to represent large integers (over 17 or so digits) as floats is going to lose precision. That can happen a number of ways, and math.pow is just one of them. Floats use a finite precision to store their value, and the radix is binary, not decimal. So figuring where they start to lose precision is tricky. If you're doing a calculation where all intermediate values are integers, you're usually better off sticking with int/long. There are many other kinds of constraints that come up in programming, and Python usually has an answer for each. But in a machine of finite size, and when we care at least a little about performance, we frequently have to pick our algorithm, our set of functions, and our data format carefully. Someone else has mentioned the decimal package and the fractions. Each of those has a lot to offer in specific situations. But none is a panacea. -- DaveA
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