You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers binary addition and logical binary shifts, both required for OCR J277 Section 2.6. You must be able to add two 8-bit binary numbers and understand the effect of left and right shifts.
Binary addition follows four simple rules:
| Addition | Result | Carry |
|---|---|---|
| 0 + 0 | 0 | 0 |
| 0 + 1 | 1 | 0 |
| 1 + 0 | 1 | 0 |
| 1 + 1 | 0 | 1 (carry 1 to the next column) |
There is one additional rule when a carry is involved:
| Addition | Result | Carry |
|---|---|---|
| 1 + 1 + 1 (carry) | 1 | 1 |
Add 01101010 + 00110101
Work from right to left, just like denary addition:
Carry: 1 1 1 1 1
0 1 1 0 1 0 1 0 (106)
+ 0 0 1 1 0 1 0 1 ( 53)
-------------------
1 0 0 1 1 1 1 1 (159)
Check: 106 + 53 = 159. Converting 10011111 to denary: 128 + 16 + 8 + 4 + 2 + 1 = 159. Correct!
OCR Exam Tip: Always show your carry digits above the calculation. This is how examiners verify your working, and you may get method marks even if the final answer is wrong.
Overflow occurs when the result of a binary addition is too large to be stored in the available number of bits. For 8-bit numbers, the maximum value is 255 (11111111).
Example of overflow:
1 1 0 0 0 0 0 0 (192)
+ 1 0 0 0 0 0 0 0 (128)
-------------------
1 0 1 0 0 0 0 0 0 (320 — 9 bits!)
The result requires 9 bits, but only 8 bits are available. The extra bit is lost, and the stored value would be 01000000 (64), which is incorrect. This is an overflow error.
OCR Exam Tip: If the exam asks you to "explain what happens" when overflow occurs, state that the result exceeds the maximum value that can be stored in the available bits, causing an incorrect value to be stored.
A binary shift moves all the bits in a binary number to the left or right by a specified number of positions. Bits shifted off the end are lost, and empty positions are filled with 0s.
A left shift moves all bits to the left. Each left shift by 1 position multiplies the value by 2.
Example: Left shift 00010110 (22) by 1 position
Before: 0 0 0 1 0 1 1 0 (22)
After: 0 0 1 0 1 1 0 0 (44)
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.