1. Number Systems and Bases (2, 8, 10, 16)
Definition – Base (Radix)
The base (or radix) is a positive integer. A number in base has an integer part and a fractional part, separated by the radix point:
- The base fixes the number of symbols: every digit satisfies .
- Positional numbering: the digit at position is multiplied by (its weight).
- Positions to the left of the point are ; to the right they are
Example – Decimal ()
Digits: .
| Position | 4 | 3 | 2 | 1 | 0 | . | −1 | −2 | −3 | −4 |
|---|---|---|---|---|---|---|---|---|---|---|
| Digit | 2 | 0 | 4 | 6 | 1 | . | 0 | 9 | 8 | 5 |
The Common Bases
| System | Radix | Symbols | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | |
| Octal | 8 | 0 – 7 | |
| Decimal | 10 | 0 – 9 | |
| Hexadecimal | 16 | 0 – 9, A=10, B=11, C=12, D=13, E=14, F=15 |
⚠️ Base 16 needs 16 symbols but only 10 digits exist, so six letters A–F are added. A digit like “8” is illegal in octal, and “2” is illegal in binary.
Numbers 0 to 15 in Each Base
| Dec | Bin | Oct | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Powers of 2 and Unit Prefixes
| Prefix | Base 10 | Base 2 (bytes) |
|---|---|---|
| Kilo | ||
| Mega | ||
| Giga | ||
| Tera | ||
| Peta |
So bytes and bytes.
Useful powers: ; ; .
⚠️ The slide prints as 125,899,906,842,624 — the leading “1,” is missing. The correct value is 1,125,899,906,842,624.
2. Conversion from Base to Base 10
Method – Expand by Weights
Multiply each digit by and add everything up (the definition formula, evaluated in decimal).
Example – Binary → Decimal
(Only the positions holding a 1 contribute.)
Example – Octal → Decimal
Example – Hexadecimal → Decimal
⚠️ Replace letters by their values before multiplying ().
3. Conversion from Base 10 to Base
Method – 3 Steps
- Convert the integer part (successive divisions by ).
- Convert the fractional part (successive multiplications by ).
- Concatenate the two results, putting the radix point between them.
flowchart LR A["X (base 10)"] --> B["Integer part"] A --> C["Fractional part"] B -->|"divide by r repeatedly<br/>keep remainders"| D["read remainders<br/>bottom → top"] C -->|"multiply by r repeatedly<br/>keep integer parts"| E["read integer parts<br/>top → bottom"] D --> F["Concatenate with radix point"] E --> F
3.1 Integer Part – Successive Divisions by
Why It Works
If , then
Dividing the quotient again gives remainder , and so on until the quotient is . The remainders are the base- digits in reverse order — the first remainder is the least significant digit.
Intro example in base 10: remainders → reading backwards gives 5216.
Example – → Octal
| Division | Quotient | Remainder |
|---|---|---|
| 354 | 5 ← LSD | |
| 44 | 2 | |
| 5 | 4 | |
| 0 | 5 ← MSD |
(matches the octal example of §2).
Example – → Binary
| ÷ 2 | 145 | 72 | 36 | 18 | 9 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Remainder | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
Read right-to-left (last remainder first): .
3.2 Fractional Part – Successive Multiplications by
Why It Works
If , then
The integer part of the product is ; keep multiplying the remaining fraction. The integer parts are the digits in normal order — the first one is the most significant (closest to the point). Stop when the fraction becomes 0.
Example – → Binary
| Step | Product | Integer digit |
|---|---|---|
| 1.25 | 1 ← MSD | |
| 0.5 | 0 | |
| 1.0 | 1 ← LSD, fraction = 0 → stop |
. Check: ✓
Example – → Binary (Full 3-Step)
- Integer: remainders →
- Fraction: → digits →
- Concatenate:
Example – Infinite (Repeating) Fraction:
The fraction comes back, so the digits repeat forever:
⚠️ A finite decimal fraction can be an infinite binary fraction. In practice you stop after a fixed number of digits, which introduces a rounding error. Watch for a fractional part that repeats — that is the sign the expansion never ends.
4. Conversion Between Other Bases
4.1 General Method: Base → Base (2 Steps)
- Convert from base to base 10 (§2).
- Convert from base 10 to base (§3).
Example – → Octal
- r 3, r 3 → ; →
4.2 Shortcut: Base → Base (Grouping)
Applies to binary → octal (, since ) and binary → hex (, since ).
Procedure
- Group the digits in blocks of , starting from the radix point:
- integer part: from the point to the left;
- fractional part: from the point to the right.
- Pad with 0s at the outer ends if needed.
- Replace each group by one base- symbol.
Example – Binary → Hex
Example – Binary → Octal
flowchart TB subgraph "Binary → Hex: group by 4 from the point" direction LR A["0010"] --> A2["2"] B["1011"] --> B2["B"] C["0001"] --> C2["1"] P["."] --> P2["."] D["0101"] --> D2["5"] E["0100"] --> E2["4"] end
⚠️ Padding zeros go on the left of the integer part and the right of the fractional part. Padding the fraction on the left (e.g. writing as ) changes its value.
4.3 Shortcut: Base → Base (Expansion)
Replace each digit by its -digit base- equivalent (keep leading zeros inside each group), then drop zeros at the outer ends.
Example – Octal → Binary ()
Example – Hex → Binary ()
4.4 Octal ↔ Hexadecimal (Through Binary)
Go through binary rather than decimal: expand to binary, then regroup. This is easier than going through base 10.
Example – Octal → Hex
⚠️ This slide’s title says , but the worked digits use . The result is correct for .
Example – Hex → Octal
Summary of Methods
| From → To | Method |
|---|---|
| Base → 10 | Sum of digit × weight |
| 10 → base | Integer: ÷ , remainders read backwards · Fraction: × , integer parts read forwards |
| → (general) | Go through base 10 |
| 2 → 8 / 16 | Group 3 / 4 bits from the point |
| 8 / 16 → 2 | Expand each digit into 3 / 4 bits |
| 8 ↔ 16 | Go through binary |
Exercises: none assigned in this chapter’s slides — practise by redoing the worked conversions above (e.g. , ).