Modul (%) in python not like in C?

Bryan Olson fakeaddress at
Tue Sep 11 06:12:20 CEST 2007

Scott David Daniels wrote:
> C, which was designed as a "high level assembly language," does not
> tightly define the results of / and % for negative numbers.  Instead
> it defines the result for positive over positive, and constrains the
> result for the others. 

Not true. Here it is again:

     When integers are divided, the result of the / operator is
     the algebraic quotient with any fractional part discarded.(87)
     If the quotient a/b is representable, the expression
     (a/b)*b + a%b shall equal a.
     87) This is often called ‘‘truncation toward zero’’.

     [International Standard ISO/IEC 9899:1999, Section 6.5.5
     Multiplicative operators, Paragraph 6 and footnote 87]


More information about the Python-list mailing list