CS Fundamentals
Learn the octal (base-8) number system — its digits, conversions, and practical applications in computing like file permissions.
Introduction
The octal number system is a base-8 system that uses eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. While not as commonly encountered as hexadecimal in modern programming, octal has important applications — particularly in Unix/Linux file permissions — and understanding it strengthens your overall grasp of number systems and conversion techniques.
Octal, like hexadecimal, exists because of its convenient relationship with binary. Since 8 is 2 raised to the power of 3 (2^3 = 8), each octal digit corresponds to exactly 3 binary digits (bits). This makes conversion between octal and binary straightforward — you simply group bits in threes.
Understanding Base-8
In the decimal system, each position represents a power of 10: ones (10^0), tens (10^1), hundreds (10^2), and so on. In octal, each position represents a power of 8: ones (8^0 = 1), eights (8^1 = 8), sixty-fours (8^2 = 64), five-hundred-twelves (8^3 = 512), and so on.
Counting in octal goes: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20... Notice there are no digits 8 or 9 — just as decimal has no single digit for ten. When you reach 7 in octal, the next number is 10 (one eight, zero ones). The octal number 10 equals decimal 8.
To distinguish octal numbers from decimal, they are often prefixed with a zero (0) or the notation (8) is specified. In programming languages like C, a leading zero indicates octal: 010 in C is not ten — it is eight!
Converting Octal to Decimal
Multiply each digit by 8 raised to the power of its position (starting from 0 on the right) and sum the results.
Example: Convert 752 (octal) to decimal. Digit 2 × 8^0 = 2 × 1 = 2. Digit 5 × 8^1 = 5 × 8 = 40. Digit 7 × 8^2 = 7 × 64 = 448. Sum: 448 + 40 + 2 = 490. So 752 octal = 490 decimal.
Example: Convert 17 (octal) to decimal. 7 × 8^0 = 7. 1 × 8^1 = 8. Sum: 8 + 7 = 15. So 17 octal = 15 decimal.
Converting Decimal to Octal
Repeatedly divide the decimal number by 8 and record remainders. Read remainders from bottom to top.
Example: Convert 215 to octal. 215 ÷ 8 = 26 remainder 7. 26 ÷ 8 = 3 remainder 2. 3 ÷ 8 = 0 remainder 3. Reading bottom to top: 327. So 215 decimal = 327 octal.
Verify: 3×64 + 2×8 + 7×1 = 192 + 16 + 7 = 215. Correct!
Converting Between Octal and Binary
This is where octal's relationship to binary shines. Each octal digit corresponds to exactly 3 binary bits.
The mapping: 0=000, 1=001, 2=010, 3=011, 4=100, 5=101, 6=110, 7=111.
Octal to Binary: Replace each octal digit with its 3-bit binary equivalent. Example: 753 octal = 111 101 011 binary (7=111, 5=101, 3=011).
Binary to Octal: Group binary digits in threes from the right, then replace each group with its octal equivalent. Example: 110 100 010 binary = 642 octal (110=6, 100=4, 010=2).
Octal in Unix/Linux File Permissions
The most common modern use of octal is in Unix/Linux file permissions. Each file has three permission sets (owner, group, others), and each set has three permissions (read=4, write=2, execute=1). Adding the values for each set gives a single octal digit.
For example, permission 755 means: owner gets 7 (4+2+1 = read+write+execute), group gets 5 (4+0+1 = read+execute), others get 5 (4+0+1 = read+execute). The chmod command in Linux uses these octal values: chmod 644 file.txt sets read+write for owner and read-only for group and others.
This is octal because each digit represents three binary bits — which perfectly maps to three permission flags (rwx).
Key Takeaways
- Octal is base-8 using digits 0-7, with each digit representing exactly 3 binary bits
- Conversion between octal and binary is instant — each octal digit maps to a 3-bit group
- Decimal-to-octal uses repeated division by 8; octal-to-decimal uses positional multiplication
- Linux file permissions are the most common modern use of octal notation
- Octal is less common than hexadecimal in modern programming but still appears in specific contexts
- Practice all conversion methods — they are frequently tested in university exams
- Understanding octal strengthens overall comprehension of positional number systems
- The prefix 0 (zero) in C code indicates an octal number — a common source of bugs for beginners
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Octal Number System — Computer Fundamentals.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Fundamentals topic.
Search Terms
computer-fundamentals, computer fundamentals, computer, fundamentals, data, representation, octal, number
Related Computer Fundamentals Topics