CSC 180.1 · Introduction to Computer Science and BASIC Programming
Our notes
1 min readPlace value
In any base b, a digit's value is digit × b^position, counting positions from 0 at the right.
| System | Base | Digits |
|---|---|---|
| Decimal | 10 | 0-9 |
| Binary | 2 | 0, 1 |
| Octal | 8 | 0-7 |
| Hexadecimal | 16 | 0-9, A(10), B(11), C(12), D(13), E(14), F(15) |
Computers use binary because electronic switches have two states (on/off).
Any base to decimal: multiply by powers
101101₂ = 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 45₁₀.
57₈ = 5×8 + 7 = 47₁₀.
2F₁₆ = 2×16 + 15 = 47₁₀.
Fraction: 0.101₂ = 1/2 + 0/4 + 1/8 = 0.625₁₀.
Decimal to any base: repeated division
Divide by the base, keep the remainders, read them from bottom to top.
45 to binary:
| ÷2 | quotient | remainder |
|---|---|---|
| 45 | 22 | 1 |
| 22 | 11 | 0 |
| 11 | 5 | 1 |
| 5 | 2 | 1 |
| 2 | 1 | 0 |
| 1 | 0 | 1 |
Reading upward: 101101₂.
Decimal fraction to binary: multiply by 2 and keep the whole parts, reading downward: 0.625 × 2 = 1.25 (1), 0.25 × 2 = 0.5 (0), 0.5 × 2 = 1.0 (1): 0.101₂.
Binary, octal and hex shortcuts
- Binary to octal: group bits in threes from the right. 101101 → 101 101 → 55₈ (check: 5×8+5 = 45 ✓).
- Binary to hex: group in fours. 101101 → 0010 1101 → 2D₁₆ (2×16+13 = 45 ✓).
- Hex to binary: each hex digit becomes four bits. A7₁₆ = 1010 0111₂ = 167₁₀.
Exams usually ask
- Convert numbers between decimal, binary, octal and hexadecimal (including fractions).
- Explain why computers use the binary system.
Common mistake
Reading the remainders from top to bottom. For whole numbers read them upward (the last remainder is the most significant bit).
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Numeral system
(opens en.wikipedia.org in a new tab)
Wikipedia, Numeral system, CC BY-SA 4.0 · licence
-
Binary number
(opens en.wikipedia.org in a new tab)
Wikipedia, Binary number, CC BY-SA 4.0 · licence
-
Hexadecimal
(opens en.wikipedia.org in a new tab)
Wikipedia, Hexadecimal, 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 Binary Number System
4 min · ≈ 18 MB · about ₦10
(opens youtube.com in a new tab)
-
Number Systems Introduction - Decimal, Binary, Octal & Hexadecimal
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
Introduction to Number Systems
9 min · ≈ 41 MB · about ₦23
(opens youtube.com in a new tab)
-
Representing Numbers and Letters with Binary: Crash Course Computer Science #4
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
Computer Number System | Binary/ Decimal/ Octal/ Hexadecimal | All Conversion in One Shot | CTA
31 min · ≈ 140 MB · about ₦79
(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.