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

rusi rustompmody at gmail.com
Wed Dec 14 06:47:28 EST 2011


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.



More information about the Python-list mailing list