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


Groups > comp.lang.python > #28715

Re: Division help in python

From garabik-news-2005-05@kassiopeia.juls.savba.sk
Newsgroups comp.lang.python
Subject Re: Division help in python
Date 2012-09-08 07:03 +0000
Organization Aioe.org NNTP Server
Message-ID <k2eqjg$csd$1@speranza.aioe.org> (permalink)
References <CAB2OTpf290sL8kncrVADr-YD1hvUP=R424C8xd+BGGivF5AdhA@mail.gmail.com> <mailman.354.1347023611.27098.python-list@python.org>

Show all headers | View raw


Chris Angelico <rosuav@gmail.com> wrote:
> On Fri, Sep 7, 2012 at 10:53 PM, Ramyasri Dodla <ramyasri20@gmail.com> wrote:
>> I am brand new to python. checking over basic stuff. I came across the
>> problem while doing so. If any body aware of the problem, kindly respond me.
>>
>>>>> 5/10
>> 0
>>>>> - 5/10
>> -1
>>
>> The second case also should yield a 'zero' but it is giving a -1
> 
> 

...

> The reason for this is that / (or in Python 3, //) rounds toward
> negative infinity, not toward zero. This allows the modulo operator

I think he means the non-obvious unary minus precedence.

-- 
 -----------------------------------------------------------
| Radovan GarabĂ­k http://kassiopeia.juls.savba.sk/~garabik/ |
| __..--^^^--..__    garabik @ kassiopeia.juls.savba.sk     |
 -----------------------------------------------------------
Antivirus alert: file .signature infected by signature virus.
Hi! I'm a signature virus! Copy me into your signature file to help me spread!

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


Thread

Re: Division help in python Chris Angelico <rosuav@gmail.com> - 2012-09-07 23:06 +1000
  Re: Division help in python garabik-news-2005-05@kassiopeia.juls.savba.sk - 2012-09-08 07:03 +0000
    Re: Division help in python Hans Mulder <hansmu@xs4all.nl> - 2012-09-08 10:09 +0200

csiph-web