Integer math question

Sean Ross sross at connectmail.carleton.ca
Tue Jan 6 12:19:00 EST 2004


"Dan Bishop" <danb_83 at yahoo.com> wrote in message
news:ad052e5c.0401041659.68460bd at posting.google.com...
> It's a feature.  The advantage of defining x // y as floor(x / y) is
> that x % y is always nonnegative.

Sorry, but x%y can be negative in Python:

>>> x, y = 5, -10
>>> x%y
-5





More information about the Python-list mailing list