Recently I've been confused about the modulo operator, %
.
It's known that a % b == a-a/b*b
when we have integers a
and b
where a > b
, and we can do this calculation by hand if a
and b
are small enough.
However, when it comes to the way a processor computes it, does the processor use the same method as previously mentioned, a-a/b*b
? Maybe just by translating the division into subtraction or addition, or is there some shifting involved perhaps?