Modulus by constant
Segher Boessenkool
segher@kernel.crashing.org
Tue Apr 20 14:03:00 GMT 2004
> Unfortunately, in this case b doesn't divide a because we're doing
> modulus.
>
> I understand the general principle: I was wondering if anybody knew the
> code well because I suspect this is a "corner" case, being unsigned
> and having the constant being multiplied by look negative if it were
> signed.
It is not unsigned. The constant 255 is of type "int" and so the
"unsigned
short" will be converted to "int", too. (6.4.4.1/5 and 6.3.1.1/2 and
6.3.1.8/1
and 6.5.5/3, in some order).
Segher
More information about the Gcc
mailing list