Binary addition, overflow and shifts
About this lesson: Binary addition, overflow and shifts
In short
Binary addition works like column addition, but you carry at 2 instead of 10. There are only four facts to learn. Tap each one.

What you'll explore
- Four rules: Adding in binary
- Binary addition works like column addition, but you carry at 2 instead of 10. There are only four facts to learn. Tap each one.
- Column addition: Add two bytes
- Work from right to left. Write the result bit underneath and the carry above the next column.
- Overflow: When 8 bits are not enough
- A register holds a fixed number of bits. If the answer needs a 9th bit, it is lost: an overflow error.
- Logical shifts: Slide the bits
- A logical shift moves every bit left or right and fills the gap with 0. Each left shift doubles the number; each right shift halves it.
- Negative numbers: Two's complement
- To store negatives, make the leftmost bit worth −128 instead of +128. A byte then holds −128 to 127. To make −n: write n, flip every bit, add 1.
- Check yourself: Shift left twice
- The byte 00110101 (53) is shifted 2 places to the left.
Also in this lesson
- Step by step
- Watch out for these
- Getting full marks
- What can a byte hold?
- More than the lesson
- Stretch your brain
- Binary maths
Words to know
- carry
- A 1 moved to the next column when a column adds to 2 or more.
- register
- A small, fast store in the processor with a fixed number of bits.
- overflow
- When a result needs more bits than the register has.
- logical shift
- Moving all bits left or right, filling gaps with 0.
- most significant bit (MSB)
- The leftmost bit, with the biggest place value.
- least significant bit (LSB)
- The rightmost bit, worth 1.
- unsigned
- A number that can only be zero or positive.
- two's complement
- A way to store negative numbers: the MSB is worth −128 in a byte.
- precision
- How exact a value is; lost when bits fall off the right.
Sources
- BBC Bitesize, GCSE Computer Science: Binary addition and shifts
- ESA: Ariane 501 Inquiry Board report (1996)
- Isaac Computer Science: Two's complement
- Python documentation: bitwise operators
← Input, variables and output · Selection: if, elif and else →