Computer Science · Ch 2 — Encoding Schemes and Number System
Octal Number System
Octal Number System
As the value of a decimal number grows, the number of bits (0/1) in its binary representation grows with it. Sometimes a binary number becomes so long that it is difficult to manage — imagine reading or copying a 16-bit or 32-bit string without a mistake. The octal number system was devised precisely for a compact representation of binary numbers.
The base-8 system
- Octal is called the base-8 system: it has a total of eight digits, 0–7.
- Positional values are expressed in powers of 8.
- Examples of octal numbers: (237.05)8, (13)8, (617.24)8.
Writing the base as a subscript
The base value is what distinguishes a number in one system from the same-looking number in another. It is written as a subscript of the number:
(70)8 → 70 read as an OCTAL number
(70)10 → 70 read as a DECIMAL number (a completely different value!)
Without the subscript, "70" is ambiguous — always carry the base along.
Why octal compresses binary so neatly: 3 bits per octal digit
Since 8 = 2^3, three binary digits are sufficient to represent any octal digit. Every octal digit stands for exactly one 3-bit pattern, so a long binary string can be read off three bits at a time as a much shorter octal string.
The decimal and binary equivalents of the 8 octal digits:
| Octal digit | Decimal value | 3-bit binary | …
| Octal Digit | Decimal Value | 3-bit Binary Number |
|---|---|---|
| 0 | 0 | 000 |
| 1 | 1 | 001 |
| 2 | 2 | 010 |
| 3 | 3 | 011 |
| 4 | 4 | 100 |
| 5 | 5 | 101 |