Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A ticket machine adds the number of tickets sold in the morning, 10101010, to the number sold in the afternoon, 01110001. Both are stored in 8-bit registers, and the total goes into an 8-bit register too.
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. 10101010 and 01110001 in 8-bit registers.
Plan. Find the true total, then see which bits fit.
Step 1. Denary. 10101010 is . 01110001 is .
Step 2. The true total. . In binary that is the 9 bits 100011011.
Step 3. What is kept. The register keeps the right-hand 8 bits, 00011011, which is .
Step 4. Explain. 283 is greater than 255, the largest value 8 bits can hold. The ninth bit has no place in the register and is lost. This is an overflow error, so the stored total is wrong.
Check. . The lost bit was worth 256.
Answer: (a) 283. (b) 27. (c) An overflow: the answer needed 9 bits and the ninth was lost.
Log in to join the discussion.
Loading…