% is not an operator [was Re: Verbose and flexible args and kwargs syntax]

Jussi Piitulainen jpiitula at ling.helsinki.fi
Wed Dec 14 08:09:48 EST 2011


rusi writes:

> On Dec 14, 1:56 pm, Jussi Piitulainen <jpiit... at ling.helsinki.fi>
> wrote:
> >
> > Is someone saying that _division_ is not defined because -42 div -5 is
> > somehow both 9 and 8? Hm, yes, I see that someone might. The two
> > operations, div and rem, need to be defined together.
> -----------------------------
> Haskell defines a quot-rem pair and a div-mod pair as follows:
> (from http://www.haskell.org/onlinereport/basic.html)
> 
> (x `quot` y)*y + (x `rem` y) == x
> (x `div`  y)*y + (x `mod` y) == x
> 
> `quot` is integer division truncated toward zero, while the result of
> `div` is truncated toward negative infinity.

Exactly what I mean. (I gave an incorrect equation but meant this.)



More information about the Python-list mailing list