CSC 180.1 · Introduction to Computer Science and BASIC Programming
Our notes
1 min readBinary addition rules
0+0 = 0; 0+1 = 1; 1+1 = 10 (write 0, carry 1); 1+1+1 = 11 (write 1, carry 1).
Worked example
1011 (11) + 0110 (6):
1011
+ 0110
------
10001
= 10001₂ = 17 ✓.
Binary subtraction
0−0 = 0; 1−0 = 1; 1−1 = 0; 0−1 = 1 borrow 1.
1101 (13) − 0101 (5) = 1000 (8) ✓.
Binary multiplication
Like decimal, with only 0 and 1: 101 (5) × 11 (3) = 101 + 1010 = 1111 (15) ✓.
Signed numbers
- Sign and magnitude: first bit 0 for +, 1 for −. In 8 bits, −5 = 1000 0101. Has two zeros (+0 and −0).
- One's complement: flip every bit of the positive number. −5 = 1111 1010.
- Two's complement (used by computers): one's complement + 1. −5 = 1111 1010 + 1 = 1111 1011.
Check: 0000 0101 (5) + 1111 1011 = 1 0000 0000; drop the carry out of 8 bits: 0000 0000 = 0 ✓.
Range in n bits: −2^(n−1) to 2^(n−1) − 1; for 8 bits −128 to 127.
Subtraction by two's complement
7 − 5 in 8 bits = 0000 0111 + 1111 1011 = 1 0000 0010 → drop the carry: 0000 0010 = 2 ✓.
Representing characters
- ASCII: 7 bits (128 characters). 'A' = 65 = 100 0001; 'a' = 97; '0' = 48; space = 32.
- Extended ASCII: 8 bits (256).
- Unicode (UTF-8, UTF-16): covers all world scripts, including Yoruba, Igbo and Hausa letters with marks and the naira sign ₦.
- BCD (binary-coded decimal): each decimal digit in 4 bits: 59 = 0101 1001.
Other data
Real numbers use floating point (a sign, mantissa and exponent, like scientific notation). Pictures are grids of pixels, each with colour numbers; sound is sampled amplitudes.
Exams usually ask
- Add, subtract and multiply binary numbers.
- Find the two's complement of a number and use it to subtract.
- Explain ASCII and Unicode.
Common mistake
Forgetting to fix the word size before taking a complement. Two's complement only makes sense for a stated number of bits (for example 8).
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
-
Two's complement
(opens en.wikipedia.org in a new tab)
Wikipedia, Two's complement, CC BY-SA 4.0 · licence
-
ASCII
(opens en.wikipedia.org in a new tab)
Wikipedia, ASCII, CC BY-SA 4.0 · licence
-
NOUN CIT 104: Introduction to Computers
NOUN course book (PDF, about 3 MB). Hardware, software and packages.
(opens nou.edu.ng in a new tab)
Watch
-
Best pick Representing Numbers and Letters with Binary: Crash Course Computer Science #4
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
Data Representation using Signed Magnitude
6 min · ≈ 27 MB · about ₦15
(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 TO HEXADECIMAL CONVERSIONS and the Fundamentals of data representation in Computer Science
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
-
AS Level Computer Science Information Representation | Binary, Hexadecimal & Data Representation
53 min · ≈ 239 MB · about ₦134
(opens youtube.com in a new tab)
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.