Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39455

Re: Confusing math problem

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 <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'indicating': 0.05; 'python': 0.09; '22,': 0.09; '2.7.3': 0.16; 'build.': 0.16; 'equal.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'least,': 0.16; 'wrote:': 0.17; '(or': 0.18; 'windows': 0.19; 'feb': 0.19; 'skip:p 30': 0.20; '(on': 0.22; 'are.': 0.22; 'subject:problem': 0.22; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'am,': 0.27; 'first,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'run': 0.28; 'fri,': 0.30; 'code': 0.31; 'point': 0.31; 'mac': 0.32; 'int': 0.33; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'said,': 0.35; 'received:209.85.220': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'compare': 0.36; "wasn't": 0.36; 'should': 0.36; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'there,': 0.38; 'to:addr:python.org': 0.39; 'your': 0.60; 'different': 0.63; '2013': 0.84; 'replicate': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=RiRN+C2izfNQaHJEIVzG10Qkbb/CL6zuNALx8Kk3CNY=; b=BZvydvaqIM5BhJwxaGz2aov31pARq2FmEjYYDC9O/BJ+YlymnLDI2ng4y9VK6hcvC5 9YtyYw6xpebJfkpTZG8j8Sp5jDp4zScwy0GvNWWK+I5Dw335P4jIzVrPS3XnVzJUV3fU faU2+vYtDf7xQbVp/pVcC1jvsvfEtB8zuc0Q7NZPlz+4BzmiLKwEjAkOwZpgku8Rlnl+ OPa1ROD5xLouPF72LhHmkcb1cPVQBZUoWe3DVLzd+sdaJrV4jgnMNfqvJKFzvShaBX+3 X7xYpj/BpoiPotVQmTnR4O7eD+CWeBrj+3nIVV6bwawsF/VHegFtI56ZIucIDgxVu/ez alng==
MIME-Version 1.0
X-Received by 10.52.29.209 with SMTP id m17mr23371475vdh.111.1361479560634; Thu, 21 Feb 2013 12:46:00 -0800 (PST)
In-Reply-To <kg5sog$lfb$1@dont-email.me>
References <kg5sog$lfb$1@dont-email.me>
Date Fri, 22 Feb 2013 07:46:00 +1100
Subject Re: Confusing math problem
From Chris Angelico <rosuav@gmail.com>
To 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.2193.1361479569.2939.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1361479569 news.xs4all.nl 6917 [2001:888:2000:d::a6]:46870
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:39455

Show key headers only | View raw


On Fri, Feb 22, 2013 at 6:33 AM, 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.append(math.pow(a,b))
>        result2.append(a**b)

First, are you aware that ** will return int (or sometimes long on
2.7.3), while math.pow() will return a float? That may tell you why
you're seeing differences. That said, though, I wasn't able to
replicate your result using 2.7.3 and 3.3.0 both on Windows - always
9183, indicating 618 of the powers are considered equal. But in
theory, at least, what you're seeing is that 37 of them compare
different in floating point on your Mac build. Something to consider:

print(set(result1)-set(result2))

That should tell you what the extra values are.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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