IFT 211 · Digital Logic Design
Our notes
1 min readAddition rules
0 + 0 = 0; 0 + 1 = 1; 1 + 1 = 10 (write 0, carry 1); 1 + 1 + 1 = 11 (write 1, carry 1).
Worked example: addition
0101 1011 (91)
+ 0011 0110 (54)
= 1001 0001 (145)
Work from the right: 1 + 0 = 1; 1 + 1 = 0 carry 1; 0 + 1 + 1 = 0 carry 1; 1 + 0 + 1 = 0 carry 1; 1 + 1 + 1 = 1 carry 1; 0 + 1 + 1 = 0 carry 1; 1 + 0 + 1 = 0 carry 1; 0 + 0 + 1 = 1. Check: 91 + 54 = 145 = 128 + 16 + 1.
Subtraction
Rules: 0 − 0 = 0; 1 − 0 = 1; 1 − 1 = 0; 0 − 1 = 1 with a borrow from the next column. In practice computers subtract by adding the two's complement (next topic), so the same adder does both jobs.
Worked example: subtraction by borrowing
1100 (12) − 0101 (5), working from the right:
- Column 1: 0 − 1 needs a borrow. Column 2 is 0, so the borrow comes from column 3 (which becomes 0); column 2 becomes 10₂, lends 1 and keeps 1; column 1 becomes 10₂ − 1 = 1.
- Column 2: 1 − 0 = 1.
- Column 3: 0 − 1 needs a borrow from column 4 (which becomes 0): 10₂ − 1 = 1.
- Column 4: 0 − 0 = 0.
- Result 0111 = 7. Check: 12 − 5 = 7.
Multiplication
Like long multiplication in decimal, but each partial product is either 0 or a shifted copy of the multiplicand.
- 1011 (11) × 101 (5): 1011 + 0000 shifted one place + 1011 shifted two places = 1011 + 101100 = 110111 (55).
- Multiplying by 2 is a shift left by one place; dividing by 2 is a shift right.
Division
Long division with subtract-and-shift: 1101 (13) ÷ 11 (3) gives quotient 100 (4) and remainder 1.
Overflow and carry
With a fixed number of bits, a result can be too big.
- Unsigned: a carry out of the top bit means overflow. 1111 0000 (240) + 0010 0000 (32) = 1 0001 0000: in 8 bits the result shows 16, wrong, because 272 needs 9 bits.
- Signed: overflow happens when two numbers of the same sign give a result of the other sign (next topic).
BCD arithmetic
In BCD each decimal digit has 4 bits. If a digit's sum is over 9 (or makes a carry), add 6 (0110) to correct it. 8 + 5 = 1101 → +0110 = 1 0011, read as BCD 13.
Exams usually ask
- Add, subtract, multiply and divide binary numbers showing carries.
- Explain overflow; do a BCD addition with the +6 correction.
Common mistake
Forgetting the carry that comes from 1 + 1 + 1, which writes 1 and carries 1.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Binary number
(opens en.wikipedia.org in a new tab)
Wikipedia, Binary number, CC BY-SA 4.0 · licence
-
Binary Addition | Binary Arithmetic | Electronics Textbook
(opens allaboutcircuits.com in a new tab)
-
Binary Subtraction | Binary Arithmetic | Electronics Textbook
(opens allaboutcircuits.com in a new tab)
-
Adder (electronics)
(opens en.wikipedia.org in a new tab)
Wikipedia, Adder (electronics), CC BY-SA 4.0 · licence
-
NPTEL: Switching Circuits and Logic Design (IIT Kharagpur, Prof. Indranil Sengupta)
Video lectures, many hours in all: watch on Wi-Fi where you can.
(opens nptel.ac.in in a new tab)
NPTEL, NPTEL: Switching Circuits and Logic Design (IIT Kharagpur, Prof. Indranil Sengupta), CC BY-NC-SA 4.0 · licence
Watch
-
Best pick Binary Addition
8 min · ≈ 36 MB · about ₦20
(opens youtube.com in a new tab)
-
How To Add and Subtract Binary Numbers | Computer Science
14 min · ≈ 63 MB · about ₦35
(opens youtube.com in a new tab)
-
Binary Addition and Subtraction Explained (with Examples)
16 min · ≈ 72 MB · about ₦40
(opens youtube.com in a new tab)
-
Multiplying in binary | Applying mathematical reasoning | Pre-Algebra | Khan Academy
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
Practise
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.