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


Groups > comp.lang.python > #65991 > unrolled thread

Re: Simple % question

Started byChris Angelico <rosuav@gmail.com>
First post2014-02-12 14:40 +1100
Last post2014-02-12 14:40 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Simple % question Chris Angelico <rosuav@gmail.com> - 2014-02-12 14:40 +1100

#65991 — Re: Simple % question

FromChris Angelico <rosuav@gmail.com>
Date2014-02-12 14:40 +1100
SubjectRe: Simple % question
Message-ID<mailman.6723.1392176426.18130.python-list@python.org>
On Wed, Feb 12, 2014 at 2:30 PM, Scott W Dunning <swdunning@cox.net> wrote:
> On Feb 11, 2014, at 6:36 PM, Chris Angelico <rosuav@gmail.com> wrote:
>>
>> The real question is: What do you expect that symbol to mean?
>>
>> Its actual meaning is quite simple. In long division, dividing one
>> number by another looks like this:
>
> Yeah I understand what the % means.  It just confused me that 1%10 was 1.  In my thought process it just didn’t work.  1/10= .1 and I just didn’t see where the remainder of 1 came in.
>

Ah, yes. When Python 2 -> Python 3 changed the meaning of / the
meaning of % got tied instead to //. But if you think about it, with
the floating-point result you're describing there, it simply makes no
sense to even ask what the remainder is. So, if you're going to use %,
use //, and then it all makes sense.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web