
May 7, 2010
3:09 a.m.
Mathias Panzenböck wrote:
Shouldn't by by mathematical definition -x // y be the same as -(x // y)? But when assign x=2, y=3 you get:
-2 // 3 -1 -(2 // 3) 0
And also:
2 // -3 -1 -2 // -3 0
And even more:
int(-2 / 3) 0 int(2 / -3) 0
I think this rather odd. Is there any deeper reason to this behaviour? I guess changing this will break a lot of code, but why does it behave like this?
It's so that: y == (y // x) * x + (y % x) is always True (assuming x != 0).