% operator with negatives

Stephen Clamage steve at taumet.com
Sun Dec 16 07:15:26 AEST 1990


scott at bbxsda.UUCP (Scott Amspoker) writes:

>Well I can really stir up the muck by pointing out that, by definition,

>    a mod 0 == a

>Therefore, the method of dividing (a/b) does not always work since b could 
>legally equal 0.

As has been pointed out before the "%" operator in C is NOT a mod 
operator, but a remainder operator.  As such it is defined in terms
of division; thus a%0 is undefined.  (The ANSI standard explicitly
says that a%0 is undefined.)
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list