Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A small processor has no instruction to multiply. It holds the number 00011100 in an 8-bit register.
Add binary in columns from the right: (write 0, carry 1) and (write 1, carry 1). An 8-bit register holds 0 to 255, so a total above 255 is an overflow. A logical shift of places left multiplies by , and right divides by ; bits shifted off the end are lost and 0s come in. In 8-bit two's complement the MSB is worth .
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Given. 00011100, which is .
Step 1. Left shift of 2. 00011100 becomes 01110000. That is .
Step 2. Check it. A left shift of 2 multiplies by , and . No 1 fell off the left, so the answer is exact.
Step 3. Right shift of 3. 00011100 becomes 00000011. That is .
Step 4. Why it is not exact. A right shift of 3 divides by . , but the 1 in the place worth 4 fell off the right end. The least significant bit is lost, so the answer is rounded down to 3.
Answer: (a) 01110000, which is 112. (b) 00000011, which is 3, because a 1 was shifted out and lost.
Log in to join the discussion.
Loading…