"modulas" operator in C

Alan Grant Finlay alanf at bruce.OZ
Fri Feb 16 13:05:20 AEST 1990


After 3 hours of tracking down a bug I found my C compiler didn't implement
the modulas operator "%" properly.  At least that's what I thought until on
further investigation I found this in Kernighan and Ritchie's manual:

	"The binary % operator yields the remainder from division of the
	 first expression by the second."

In short it turns out that the meaning of remainder is machine dependent and
normally this means (-1)%2 results in the value -1.

This is a gripe that probably keeps recurring but specifically I have the
following request.  Would the C community stop referring to this operator as
a modulas operator and call it something else like a "remainder" operator.



More information about the Comp.lang.c mailing list