Re: [Python-ideas] division oddness

2010-05-06 Thread Xavier Ho
On Fri, May 7, 2010 at 12:14 PM, Chris Rebert wrote: > Personally, I find the following the most unintuitive: > divmod(-11, 3) == (-4, 1) > > So, we overshoot -11 and then add 1 to go back to the right place? > That violates my intuitive thought that abs((n//d)*d) <= abs(n) ought to > hold. > Ha

Re: [Python-ideas] division oddness

2010-05-06 Thread Terry Reedy
On Thu, May 6, 2010 at 5:43 PM, Mathias Panzenböck Shouldn't by mathematical definition -x // y be the same as -(x// y)? Tradeoffs, tradeoffs. Most everyone agrees on this rule for the relation between // and %: x == y*(x//y) + x%y If // is defined as above, then, for instance, x%2 has 3

Re: [Python-ideas] division oddness

2010-05-06 Thread Chris Rebert
On Thu, May 6, 2010 at 6:33 PM, Xavier Ho wrote: > On Fri, May 7, 2010 at 11:13 AM, Chris Rebert wrote: >> On Thu, May 6, 2010 at 5:43 PM, Mathias Panzenböck >> wrote: >> > Shouldn't by mathematical definition -x // y be the same as -(x // y)? >> > I think this rather odd. Is there any deeper re

Re: [Python-ideas] division oddness

2010-05-06 Thread Xavier Ho
On Fri, May 7, 2010 at 11:13 AM, Chris Rebert wrote: > On Thu, May 6, 2010 at 5:43 PM, Mathias Panzenböck > wrote: > > Shouldn't by mathematical definition -x // y be the same as -(x // y)? > > I think this rather odd. Is there any deeper reason to this behaviour? I > > guess changing this will