Integer division

John Hofbauer hofbauer at utcsri.UUCP
Mon Feb 10 10:21:24 AEST 1986


> This % vs. Mod debate is rather silly.  C's % operator is
> NOT repeat NOT intended to be a modulo operator, although
> people often use it that way for positive operands.  All
> reasonable mathematicians agree on what the definition of
> 	a mod b
> is for positive b and negative a.  That should not be
> confused with what the result of
> 	a % b
> should be under similar circumstances.  C intentionally
> hedges a bit on the meaning of % 

To paraphrase Alice In Wonderland loosely, an operator means
whatever you want it to mean, nothing more, nothing less.
The remainder of a machine integer division is defined as
being whatever the engineer's found convenient to implement.
Any resemblance to mathematics is purely coincidental.



More information about the Comp.lang.c mailing list