% operator with negatives

Doug Gwyn gwyn at smoke.brl.mil
Thu Dec 13 07:40:18 AEST 1990


In article <1990Dec12.185714.7169 at mp.cs.niu.edu> t901908 at mp.cs.niu.edu (Joe Adamo) writes:
>I know this may sound silly, but what is the effect of using the 
>% (mod) operator with negatives?  I can't seem to find any info on it.

Two things:  % is NOT a modulo operator; it's a remainder operator, which
is not the same thing.  Also, for negative operands there are implementation-
dependent aspects to the result obtained; in most applications you should
avoid using negative operands.



More information about the Comp.lang.c mailing list