Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65991
| References | <63EBCBF1-6C1B-4B8B-9D4A-0567CBDA978A@cox.net> <4ED77821-6237-484F-A6BF-5B970CC6560B@cox.net> |
|---|---|
| Date | 2014-02-12 14:40 +1100 |
| Subject | Re: Simple % question |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6723.1392176426.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Simple % question Chris Angelico <rosuav@gmail.com> - 2014-02-12 14:40 +1100
csiph-web