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 possible values
(-1, 0, 1) rather than just 2. Not so good. Since y is usually positive
in practical applications (what does dividing by a negative number
mean?), having the sign of x%y governed by the sign of y rather than the
sign of x seems advantageous.
Judging from the chart at
http://en.wikipedia.org/wiki/Modulo_operation
languages are pretty evenly split on which definitions to use.
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list