Ben Bacarisse said:

I'm not sure what you mean. % is odd in that it takes only integer

arguments yet it performs the usual arithmetic conversions designed to

establish "a common real type" for the operands.

The more I think about it, the odder % looks. It could be defined like

the shift operators to do only integer promotions and to yield a value

whose type is that of the promoted left operand. That would give it

more natural semantics, and, contrary to what I said above, would not be

odd at all.

The argument I would make (that is, defending the status quo) is

that % is an operation whose operand values come from the same

"field" or set of values, kind of a derived operation from

multiplication and addition. Shift operations, on the other

hand, have operands that come from very different domains; it

happens that in C both of those domains are (subsets of)

integers, but at some level that's just coincidence.

An example analogy: suppose our "field" were polynomials (over

a single variable) rather than integers. If P1 and P2 are

polynomials, it still makes sense to say

P1 % P2

but no sense to say

P1 << P2

whereas

P1 << N

could quite plausibly be defined, for example as P1 * X^N.

Considering the above, it makes sense for % to have the

same promotion rules as * and /.