Integer dicision

casevh casevh at gmail.com
Fri Apr 11 01:06:53 EDT 2008


On Apr 10, 9:28 pm, bdsatish <bdsat... at gmail.com> wrote:
> How does (a/b) work when both 'a' and 'b' are pure integers ?

Python defines the quotient and remainder from integer division so
that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be
negative.

>>> divmod(-9,2)
(-5, 1)
>>> divmod(9,2)
(4, 1)

casevh



More information about the Python-list mailing list