On Thu, 2006-08-03 at 13:51, Michael Yanowitz wrote: > Hello: > > Just wondering if this is a bug, is this as designed, > or do I have to import math or something to make it correct: > > I was just screwing around. > and found: > >>> -1/100 > -1 > Shouldn't it be zero? > 1/100 returns 0 > but -1/ANY_POSITIVE_INTEGER_NUMBER > returns -1 > > >>> -10/3 > -4 > > It behaves correct for positive numbers, but for negative > integers it seems to subtract one from the expected result.
It behaves correctly in both cases. Your expectation is incorrect. http://docs.python.org/ref/binary.html says: """ Plain or long integer division yields an integer of the same type; the result is that of mathematical division with the `floor' function applied to the result. """ The floor of x is the largest integer number that's less than or equal to x. The floor of -0.01 is -1. HTH, Carsten. -- http://mail.python.org/mailman/listinfo/python-list