[Python-ideas] division oddness

Mathias Panzenböck grosser.meister.morti at gmx.net
Fri May 7 02:43:42 CEST 2010


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?

	-panzi



More information about the Python-ideas mailing list