Number systems: base and place value
Every number system has a base (radix) = how many digits it uses. Each place is worth baseposition.
| System | Base | Digits |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0–7 |
| Decimal | 10 | 0–9 |
| Hexadecimal | 16 | 0–9, A(10)–F(15) |
We write the base as a subscript: (1011)2, (17)8, (2F)16.
Decimal to binary, octal and hexadecimal
Whole part: divide by the new base again and again, write each remainder, stop at 0, and read remainders from bottom to top.
Example: 25 → binary: 25÷2 = 12 r1, 12÷2 = 6 r0, 6÷2 = 3 r0, 3÷2 = 1 r1, 1÷2 = 0 r1 → (11001)2.
Fraction part: multiply by the base, take the whole-number part as the next digit, repeat with the fraction, read top to bottom. Example: 0.625 × 2 = 1.25 (1), 0.25 × 2 = 0.5 (0), 0.5 × 2 = 1.0 (1) → (0.101)2.
Binary, octal and hexadecimal to decimal
Multiply each digit by its place value and add.
(1101)2 = 1×8 + 1×4 + 0×2 + 1×1 = 13.
(157)8 = 1×64 + 5×8 + 7×1 = 111.
(2F)16 = 2×16 + 15×1 = 47.
After the point the places are base−1, base−2…: (10.11)2 = 2 + 0.5 + 0.25 = 2.75.
Binary ↔ octal ↔ hexadecimal
8 = 2³, so one octal digit = 3 bits. 16 = 2⁴, so one hex digit = 4 bits.
Binary → octal/hex: group bits from the right (add 0s on the left if needed) and write each group's value. (11010110)2 → 011 010 110 → (326)8; 1101 0110 → (D6)16.
Octal/hex → binary: write each digit as 3 or 4 bits. (5A)16 = 0101 1010.
Octal ↔ hex: go through binary.
Encoding schemes: ASCII, ISCII and Unicode
A computer stores every character as a number called its code. An encoding scheme is the agreed table of codes.
- ASCII: 7 bits, 128 characters (English letters, digits, symbols). A = 65, a = 97, 0 = 48, space = 32.
- ISCII (Indian Script Code for Information Interchange): 8 bits, 256 codes; keeps ASCII in the first 128 and uses the rest for Indian scripts like Devanagari.
- Unicode: one code point for every character of every script (like U+0905 for अ), plus symbols and emoji.
Unicode code points are stored using UTF formats:
- UTF-8: variable length, 1 to 4 bytes. English letters take 1 byte (same as ASCII), Hindi letters 3 bytes, emoji 4. Most web pages use it.
- UTF-32: fixed length, every character takes 4 bytes. Simple to index but uses more space.
Board exam focus
Expect 1–3 mark conversions (show every division or multiplication step), 'why is Unicode needed', and UTF-8 vs UTF-32.
Key formulas and definitions
- Value = Σ digit × base^position
- Decimal → base b: divide by b, read remainders bottom → top
- Fraction → base b: multiply by b, read integer parts top → bottom
- 1 octal digit = 3 bits; 1 hex digit = 4 bits
- A = 65, a = 97, '0' = 48 (ASCII)
- UTF-8: 1–4 bytes; UTF-32: 4 bytes
Worked examples
1. Convert (45)₁₀ to binary.
45÷2=22 r1; 22÷2=11 r0; 11÷2=5 r1; 5÷2=2 r1; 2÷2=1 r0; 1÷2=0 r1. Read up: (101101)₂.
2. Convert (110110)₂ to decimal.
32 + 16 + 0 + 4 + 2 + 0 = 54.
3. Convert (156)₁₀ to hexadecimal.
156÷16 = 9 r12 (C); 9÷16 = 0 r9. Read up: (9C)₁₆.
4. Convert (725)₈ to binary and then to hexadecimal.
7 = 111, 2 = 010, 5 = 101 → 111010101. Groups of 4 from the right: 0001 1101 0101 → (1D5)₁₆.
5. Convert (0.375)₁₀ to binary.
0.375×2 = 0.75 (0); 0.75×2 = 1.5 (1); 0.5×2 = 1.0 (1). Read down: (0.011)₂.
6. Convert (1A.8)₁₆ to decimal.
1×16 + 10×1 + 8×16⁻¹ = 16 + 10 + 0.5 = 26.5.
7. How many bytes does 'नमस्ते' (6 Unicode characters) take in UTF-8 and in UTF-32?
Each Devanagari character is 3 bytes in UTF-8: 6 × 3 = 18 bytes. In UTF-32 each is 4 bytes: 6 × 4 = 24 bytes.
Common mistakes
- Reading remainders top to bottom. For whole numbers read them bottom to top.
- Grouping bits from the left. Always group from the right (for the whole part).
- Writing hex digits above 9 as numbers (like 12) instead of letters (C).
- Thinking ASCII can store Hindi letters. ASCII has only 128 English-based characters; Hindi needs ISCII or Unicode.