7.5 Dividing 2's complement integers
Just as multiplication can be turned into repeated additions, so division can be turned into repeated subtractions. And just
as shifting a binary integer one place to the left equates to multiplying by two, so shifting a binary integer one place to the right equates to dividing by two.
Activity 27 (Exploratory)
How many places to the right do you think you would need to shift a binary integer to achieve division by eight?
Now read the discussion
Comment
You probably guessed that if shifting one place to the right is dividing by two then shifting two places to the right is dividing
by four and shifting three places to the right is dividing by eight. And this is indeed the case.
Note that in integer arithmetic a fractional result is not possible. So if the divisor does not go exactly into the number
to be divided then the result will have to be in the form of ‘it divides in such-and-such a number of times, with a remainder
of such-and-such’.
|