Add binary numbers with carries, recognise overflow, and use left and right shifts to multiply and divide.
What you will learn
- Add two or three binary numbers
- Explain overflow
- Carry out left and right shifts and say their effect
Adding in binary
Add from the right, column by column, just as in denary.
| Sum | Write | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 1 | 0 | 1 |
| 1 + 1 + 1 | 1 | 1 |
The rules for one column: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1). A worked example:
- Add 0011 0110 (54) and 0001 1011 (27).
- Right column: 0 + 1 = 1. Next: 1 + 1 = 10, write 0 carry 1. Next: 1 + 0 + carry 1 = 10, write 0 carry 1.
- Next: 0 + 1 + carry 1 = 10, write 0 carry 1. Next: 1 + 1 + carry 1 = 11, write 1 carry 1.
- Next: 1 + 0 + carry 1 = 10, write 0 carry 1. Next: 0 + 0 + carry 1 = 1. Left column: 0 + 0 = 0.
- Answer: 0101 0001, which is 81 = 54 + 27.
To add three numbers, add the first two, then add the third to that answer.
Always check in denary: convert both numbers, add, and convert back.
A register is a small store inside the processor that holds a fixed number of bits. Overflow happens when the result needs more bits than there are. Adding two 8-bit numbers whose total is over 255 produces a ninth bit; in an 8-bit register it is lost and the stored answer is wrong.
The rest of this lesson and its 7 practice questions are locked.
In this lesson
- Adding in binary
- Binary shifts
- Try it: Add two numbers
7 practice questions, marked as you go; about 20 minutes in all.
Key terms
Register, Overflow, Left shift, Right shift
In this unit: Data representation
Binary, denary and hexadecimal, binary addition and shifts, two's complement, and how characters, images and sound are stored and compressed.
- Binary, denary and hexadecimal
- Binary addition and shifts
- Negative numbers in binary
- Characters and images
- Sound and compression