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


Groups > comp.lang.python > #58549

Re: Help me with this code

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'subject:code': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Help': 0.11; 'python': 0.11; 'precedence': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rules.': 0.16; 'so)': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; '2.x': 0.24; 'integer': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'division': 0.31; 'maybe': 0.34; 'subject:with': 0.35; 'should': 0.36; 'two': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; "you're": 0.61; 'email addr:gmail.com': 0.63; 'subject:this': 0.83; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Help me with this code
Date Tue, 05 Nov 2013 23:44:21 -0600
References <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com> <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host pool-108-12-85-29.hstntx.dsl-w.verizon.net
In-Reply-To <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com>
User-Agent Groundhog Newsreader for Android
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2074.1383716672.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1383716672 news.xs4all.nl 15976 [2001:888:2000:d::a6]:35309
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:58549

Show key headers only | View raw


On Tue, 5 Nov 2013 17:51:00 -0800 (PST), chovdary@gmail.com wrote:
>         result  +=  ((-1) ** (k+1))/2*k-1

One of two things are happening here. Maybe both.

You're using Python 2.x (and should havesaid so) where integer 
division is truncated.

You're missing around some part of the intended denominator. Check 
operator precedence rules.

-- 
DaveA

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


Thread

Help me with this code chovdary@gmail.com - 2013-11-05 17:51 -0800
  Representing fractions (was: Help me with this code) Ben Finney <ben+python@benfinney.id.au> - 2013-11-06 13:06 +1100
  Re: Help me with this code MRAB <python@mrabarnett.plus.com> - 2013-11-06 02:37 +0000
  Re: Help me with this code Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-06 02:42 +0000
  Re: Help me with this code Dave Angel <davea@davea.name> - 2013-11-05 23:44 -0600
  Re: Help me with this code Piet van Oostrum <piet@vanoostrum.org> - 2013-11-07 09:08 -0400

csiph-web