Converting between octal and binary
One octal digit is exactly 3 bits, so converting between octal and binary is a matter of grouping.
Octal to binary
Write each octal digit as 3 bits.
| Octal | Bits | Octal | Bits |
|---|---|---|---|
| 0 | 000 | 4 | 100 |
| 1 | 001 | 5 | 101 |
| 2 | 010 | 6 | 110 |
| 3 | 011 | 7 | 111 |
Example: 745. 7 is 111, 4 is 100, 5 is 101. The answer is 111100101.
Binary to octal
Split the bits into groups of 3 from the right, adding leading zeros to the left group if needed, then write one octal digit per group.
Example 1: 101110. Groups: 101 and 110. That is 5 and 6, so 56.
Example 2: 1101011. Groups from the right: 011, 101 and 1. Pad the left group: 001. That gives 1, 5 and 3, so 153.
Check with decimal
56 in octal is 5 x 8 + 6 = 46, and 101110 in binary is 32 + 8 + 4 + 2 = 46. They match.
Practise it
In Binary Practice, open Training and choose binary to octal or octal to binary.
Also see binary to hexadecimal, which groups bits in fours.