John Salerno wrote: > Hi all. I'm just starting out with Python, so I'm a little slow right > now. :) > > Can someone explain to me why the expression 5 / -2 evaluates to -3, > especially considering that -2 * -3 evaluates to 6? > > I'm sure it has something to do with the negative number and the current > way that the / operator is implemented, but why doesn't it evaluate to > -2 instead?
Its an integer expression. Try '5.0/-2' or '5/-2.0' or 'float(5)/-2' or '5/float(-2)' and compare '5/-2' to '5/2'. James -- http://mail.python.org/mailman/listinfo/python-list