% operator with negatives

Dave Rackley drack at titan.tsd.arlut.utexas.edu
Fri Dec 14 04:25:49 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.

In article <14722 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:

   >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.

Hmmm?  You answer is correct, except _K & R 2d edition_, page 41, refers to 
 % as the modulus operator.  Prentice Hall must have missed it during
their review.  I agree, one should avoid negative operands with %.

--

  DISCLAIMER?  I don't know anything 'bout any ol' disclaimer!         

+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+
| David Rackley		        |                                             |
| Applied Research Laboratories |      It's OK to be a martyr, as long as     |
| The University of Texas       |      you don't bring your own firewood.     |
| Austin, TX.  78758            |                          -- Dr. James Rigby |
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+



More information about the Comp.lang.c mailing list