At 4:10 PM +0200 4/12/07, Ovanes Markarian wrote:
the standart states in [expr.mul] ยง5.6 section 4: The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined; otherwise (a/b)*b + a%b is equal to a. If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined...
Note that C++ follows C89 in this. C99 changed this and defined division to truncate toward zero (following Fortran, according the C99 rationale). Interestingly, the draft C++ update (n2135) retains the original wording and has not been updated to match C99. That's Core Issue 614, so may change before the next C++ revision is finalized.