Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #58549
| From | Dave Angel <davea@davea.name> |
|---|---|
| Subject | Re: Help me with this code |
| Date | 2013-11-05 23:44 -0600 |
| References | <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com> <612c0028-ae66-4200-b9a5-a613eca94762@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2074.1383716672.18130.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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