Computers work entirely with binary digits (0 and 1). To represent numbers, text, images, and sound in this binary world, we use number systems and encoding schemes. This chapter forms the mathematical backbone of how computers store and process every piece of information.
Number Systems
A number system defines how numbers are represented using a fixed set of symbols and a base (radix).
| System | Base | Digits Used |
|--------|------|-------------|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0 - 7 |
| Decimal | 10 | 0 - 9 |
| Hexadecimal | 16 | 0 - 9, A - F |
Positional value: Each digit's value = digit x baseposition. Position starts at 0 from the right.
Conversion Techniques
Decimal to Binary: Repeatedly divide by 2 and collect remainders bottom-up.
Binary to Decimal: Multiply each bit by 2 raised to its position and sum all products.
Binary to Octal: Group bits in sets of 3 from right; convert each group.
Binary to Hexadecimal: Group bits in sets of 4 from right; convert each group.
Decimal to Hexadecimal: Divide by 16, collect remainders (use A-F for 10-15).
Encoding Schemes
ASCII (American Standard Code for Information Interchange): Uses 7 bits to represent 128 characters (0-127). Extended ASCII uses 8 bits (256 characters). Includes control characters, digits, uppercase and lowercase letters, and symbols.
- Key ASCII values to remember:
- '0' = 48, '9' = 57
- 'A' = 65, 'Z' = 90
- 'a' = 97, 'z' = 122
Unicode: ASCII could not represent all world scripts. Unicode was designed to cover every character in every language. UTF-8 is the most common encoding, using 1-4 bytes per character and remaining backward-compatible with ASCII. UTF-16 uses 2-4 bytes; UTF-32 uses a fixed 4 bytes.
ISCII (Indian Script Code for Information Interchange): An encoding standard developed for Indian languages, using 8 bits. It supports Devanagari and other Indic scripts.
Units of Data
Key formulas
Worked Examples
Convert (45)10 to binary.
45 / 2 = 22 remainder 1
22 / 2 = 11 remainder 0
11 / 2 = 5 remainder 1
5 / 2 = 2 remainder 1
2 / 2 = 1 remainder 0
1 / 2 = 0 remainder 1
Reading remainders bottom-up: (101101)2
Convert (101101)2 to decimal.
1x25 + 0x24 + 1x23 + 1x22 + 0x21 + 1x20
= 32 + 0 + 8 + 4 + 0 + 1 = (45)10
Convert (11010110)2 to octal.
Group into threes from right: 011 010 110
011 = 3, 010 = 2, 110 = 6
Result: (326)8
Convert (11010110)2 to hexadecimal.
Group into fours from right: 1101 0110
1101 = 13 = D, 0110 = 6
Result: (D6)16
Convert (2BF)16 to decimal.
2x162 + 11x161 + 15x160
= 512 + 176 + 15 = (703)10
What is the ASCII code of the character 'C'?
ASCII of 'A' = 65. 'C' is 2 positions after 'A', so ASCII of 'C' = 65 + 2 = 67.
How many characters can UTF-32 represent compared to ASCII?
ASCII (7-bit) represents 27 = 128 characters. UTF-32 uses 32 bits, so it can represent 232 = 4,294,967,296 code points — covering all scripts, symbols, and emoji worldwide.
Common mistakes
> When converting binary to octal, always group from the right and pad with leading zeros on the left if needed. For example, 1011010 becomes 001 011 010 = (132)8, not grouping from the left. Also remember that hexadecimal digits A-F represent decimal values 10-15.
Summary
Computers use the binary number system internally. Programmers often use octal and hexadecimal as shorthand for binary. Converting between these bases requires understanding positional value. Encoding schemes like ASCII, Unicode (UTF-8, UTF-16, UTF-32), and ISCII map characters to binary codes so computers can store and process text from any language.