modulus on negative numbers

Quote:

> Is the result of using the % operator on negative numbers

> implementation defined in C89/C90?

> AFAIK it is well defined in C99 because of the

> (a/b)*b + a%b == a always true guarantee.

The 1988 draft says: "If either operand is negative, whether the result

of the / operator is the largest integer less than the algebraic

quotient or the smallest integer greater than the algebraic quotient is

implementation-defined, as is the sign of the result of the % operator."

--

"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.

C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

K&R answers, C books, etc: http://users.powernet.co.uk/eton