
































So coming back to our original problem given the modulo- representation
, we would
like to round
to
, where
is the smallest multiple of
such that
.
To accomplish this task we need to examine the first (from right)
digits in the modulo-
representation of
. In fact the value of in those
bits is the reminder we get when we
divide
by
, so if
is the value in those
bits then
. When
we can elegantly use the bit-wise operators to accomplish this. So if some one gives
an integer
and ask to find a smallest
which is a multiple of
then we
use the following C-statement to accomplish this
.
Where
are the standard bit-wise operators in C.