If you have the C99 standard handy anyway, this is clearly stated on page 82 :) 6.5.5.5: --- The result of the / operator is the quotient from the division of the first operand by the second; the result of the % operator is the remainder. In both operations, if the value of the second operand is zero, the behavior is undefined. --- So negatives are allowed in the C99 standard. I don't have a copy of the C89 standard so I can't quote that one. Plan 9 C isn't C99 so I'm not sure any of this is even relevant ot the list. In The C Programming Language ["draft ANSI Version" that I got from a college professor who was retiring] it says that the expression x % y produces the remainder when x is divided by y. Dave On 12/17/05, David Leimbach wrote: > > C's 'mod' isn't really mod. It's actually remainder. It's always been > this way to my knowledge. > > If you want a real "mod" use Python or Ada :) > > Dave > > On 12/15/05, Jack Johnson wrote: > > > > Not really, but all the talk about Singularity got me poking around > > and I came across this: > > > > ------ > > > > How are the functions DIV and MOD defined? > > > > The following answers are given by the Internal Working Document on > > the Common Language Infrastructure (CLI). > > > > result = value1 DIV value2 satisfies the following conditions: > > |result| = |value1| / |value2|, and > > sign(result) = +, if sign(value1) = sign(value2) > > sign(result) = - , if sign(value1) # sign(value2) > > > > result = value1 MOD value2 satisfies the following conditions: > > result = value1 - value2 * (value1 DIV value2), and > > 0 <= |result| < |value2|, and > > sign(result) = sign(value1) > > > > Please note that this definition of DIV and MOD differs from the > > definition given in [M. Reiser, N. Wirth. Programming in Oberon. p. > > 36]: > > x = (x DIV y) * y + (x MOD y), and > > 0 <= (x MOD y) < y > > > > ( from http://www.bluebottle.ethz.ch/oberon.net/faq.html#ad_DivMod ) > > > > ------ > > > > I kind of collect random, older computer science texts, so I cracked > > open The Nature of Computation by Pohl and Shaw, which yields: > > > > "x MOD y = x - (x ÷ y) * y, where ÷ indicates integer division (i.e. > > fractions are disregarded; equivalently, the result of the division is > > truncated)." > > > > So, what *is* -5 MOD 3? > > > > -Jack > > > >