modulus fn with negatives

Brian Westley brian at digi-g.UUCP
Wed Aug 29 00:18:55 AEST 1984


<Arthur bruised his upper arm>

Should ((-2) % 3) equal -2 or 1?  Our machine returns -2, but the posted
corewars game seems to assume a%b always returns 0..b-1; is modulus for
negative lefthand args well defined?  What about Pascal mod function?
Modula Modulus?  Accepted mathematical definition of modulus?
						Merlyn % Leroy



More information about the Comp.lang.c mailing list