Binary to Octal Conversion: Complete Guide with Table, Examples & Code
Learn how to convert binary to octal using the 3-bit grouping method. Includes a complete conversion table (0-255), step-by-step examples, Python/JavaScript/C code, and practical applications in Unix file permissions.
Binary to Octal Conversion: Complete Guide with Table, Examples & Code
Binary-to-octal conversion is one of the cleanest operations in number system arithmetic. Because octal is base-8 and 8 is an exact power of 2 (2³ = 8), every single octal digit maps to exactly three binary bits. No rounding, no remainders, no messy long division -- just a direct, mechanical substitution. This relationship made octal a favorite notation in early computing, and it remains essential today for anyone working with Unix/Linux file permissions, legacy codebases, or embedded systems.
This guide covers the complete theory and practice of binary-to-octal conversion. You will learn why the conversion works, how to perform it by hand, how to handle edge cases like odd-length binary strings, and how to write code that does it for you. Try our free binary to octal converter to follow along with any of the examples below.
Number Systems Overview
Before diving into the conversion itself, it helps to understand the four number systems that programmers encounter most often.
Binary (Base-2)
Binary uses only two symbols: 0 and 1. Every digital computer is built on binary logic because transistors operate in two states -- on and off. While binary is the native language of hardware, it is verbose for humans: the decimal number 255 requires eight binary digits (11111111).
Octal (Base-8)
Octal uses eight symbols: 0 through 7. Each octal digit represents exactly three binary bits, making it a compact shorthand for binary data. Octal was especially popular on systems with 12-bit, 24-bit, and 36-bit word lengths, where the word size divides evenly by three.
Decimal (Base-10)
Decimal uses ten symbols: 0 through 9. It is the system humans grow up with and use in everyday life. However, decimal does not align neatly with binary -- there is no whole number n such that 10 = 2^n -- which makes decimal-to-binary conversion require repeated division.
Hexadecimal (Base-16)
Hexadecimal uses sixteen symbols: 0-9 and A-F. Each hex digit maps to exactly four binary bits (since 16 = 2^4). Hex dominates modern computing for memory addresses, color codes, and byte-level data inspection. For hex-to-binary conversion, see our hex to binary guide.
Why Binary and Octal Are Directly Related
The key insight behind binary-to-octal conversion is a simple mathematical fact: 8 = 2³. Because the octal base is an exact power of the binary base, each octal digit corresponds to a fixed number of binary digits -- specifically, three.
This means:
- Octal digit 0 = binary 000
- Octal digit 1 = binary 001
- Octal digit 7 = binary 111
Every possible combination of three binary bits (there are exactly 2³ = 8 of them) maps to one of the eight octal digits. This is not a coincidence or an approximation. It is an exact structural relationship between the two number systems.
Compare this to decimal: converting binary to decimal requires positional arithmetic because 10 is not a power of 2. Converting binary to octal requires nothing more than grouping and substitution.
This same principle applies to hexadecimal (16 = 2^4, so each hex digit = 4 bits) but not to, say, base-5 or base-12, which have no clean power-of-two relationship.
The 3-Bit Grouping Method Step by Step
Converting binary to octal is a three-step mechanical process.
Step 1: Start from the Right and Group into 3-Bit Chunks
Take the binary number and, beginning at the rightmost (least significant) bit, divide it into groups of three.
For example, the binary number 110101011:
1 | 101 | 011 (grouped from right)
Step 2: Pad the Leftmost Group with Leading Zeros
If the leftmost group has fewer than three bits, add zeros on the left to complete it. This does not change the value of the number.
001 | 101 | 011 (padded)
Step 3: Replace Each 3-Bit Group with Its Octal Digit
Use the conversion table (provided in the next section) to substitute each group:
- 001 = 1
- 101 = 5
- 011 = 3
Result: Binary 110101011 = Octal 153
That is the entire algorithm. No division, no modular arithmetic, no carrying -- just grouping, padding, and substitution.
3-Bit Quick Reference Table (000-111)
This is the core lookup table you need to memorize for binary-to-octal conversion. There are only eight entries:
| Binary | Octal | Decimal |
|---|---|---|
| 000 | 0 | 0 |
| 001 | 1 | 1 |
| 010 | 2 | 2 |
| 011 | 3 | 3 |
| 100 | 4 | 4 |
| 101 | 5 | 5 |
| 110 | 6 | 6 |
| 111 | 7 | 7 |
Since octal digits range from 0 to 7, this table is exhaustive. Once you internalize these eight mappings, you can convert any binary number to octal by hand in seconds.
Worked Examples
Example 1: Short Binary (6 bits)
Binary input: 101110
Step 1: Group from the right: 101 | 110
Step 2: Both groups are already 3 bits. No padding needed.
Step 3: Convert:
- 101 = 5
- 110 = 6
Result: Octal 56 (decimal 46)
Example 2: Full Byte (8 bits)
Binary input: 11010110
Step 1: Group from the right: 11 | 010 | 110
Step 2: Pad the leftmost group: 011 | 010 | 110
Step 3: Convert:
- 011 = 3
- 010 = 2
- 110 = 6
Result: Octal 326 (decimal 214)
Notice that one byte (8 bits) always produces either two or three octal digits, since 8 is not evenly divisible by 3. This is one reason hexadecimal (where one byte = exactly two hex digits) became more popular than octal for byte-oriented architectures.
Example 3: Odd-Length Binary (5 bits)
Binary input: 10011
Step 1: Group from the right: 10 | 011
Step 2: Pad: 010 | 011
Step 3: Convert:
- 010 = 2
- 011 = 3
Result: Octal 23 (decimal 19)
Example 4: Long Binary (16 bits)
Binary input: 1100100111010110
Step 1: Group from the right: 1 | 100 | 100 | 111 | 010 | 110
Step 2: Pad: 001 | 100 | 100 | 111 | 010 | 110
Step 3: Convert:
- 001 = 1
- 100 = 4
- 100 = 4
- 111 = 7
- 010 = 2
- 110 = 6
Result: Octal 144726 (decimal 51,670)
Example 5: All Ones
Binary input: 111111111 (nine 1-bits)
Step 1: Group: 111 | 111 | 111
Step 2: No padding needed (already aligned).
Step 3: Convert: 111 = 7, 111 = 7, 111 = 7
Result: Octal 777 (decimal 511)
This value is significant in Unix permissions -- chmod 777 grants read, write, and execute permissions to owner, group, and others.
Extended Conversion Table (0-127)
The following table lists binary, octal, and decimal values for numbers 0 through 127. This covers the full 7-bit ASCII range and the most commonly encountered values.
| Decimal | Binary | Octal | Decimal | Binary | Octal |
|---|---|---|---|---|---|
| 0 | 000 000 | 00 | 64 | 1 000 000 | 100 |
| 1 | 000 001 | 01 | 65 | 1 000 001 | 101 |
| 2 | 000 010 | 02 | 66 | 1 000 010 | 102 |
| 3 | 000 011 | 03 | 67 | 1 000 011 | 103 |
| 4 | 000 100 | 04 | 68 | 1 000 100 | 104 |
| 5 | 000 101 | 05 | 69 | 1 000 101 | 105 |
| 6 | 000 110 | 06 | 70 | 1 000 110 | 106 |
| 7 | 000 111 | 07 | 71 | 1 000 111 | 107 |
| 8 | 001 000 | 10 | 72 | 1 001 000 | 110 |
| 9 | 001 001 | 11 | 73 | 1 001 001 | 111 |
| 10 | 001 010 | 12 | 74 | 1 001 010 | 112 |
| 11 | 001 011 | 13 | 75 | 1 001 011 | 113 |
| 12 | 001 100 | 14 | 76 | 1 001 100 | 114 |
| 13 | 001 101 | 15 | 77 | 1 001 101 | 115 |
| 14 | 001 110 | 16 | 78 | 1 001 110 | 116 |
| 15 | 001 111 | 17 | 79 | 1 001 111 | 117 |
| 16 | 010 000 | 20 | 80 | 1 010 000 | 120 |
| 17 | 010 001 | 21 | 81 | 1 010 001 | 121 |
| 18 | 010 010 | 22 | 82 | 1 010 010 | 122 |
| 19 | 010 011 | 23 | 83 | 1 010 011 | 123 |
| 20 | 010 100 | 24 | 84 | 1 010 100 | 124 |
| 21 | 010 101 | 25 | 85 | 1 010 101 | 125 |
| 22 | 010 110 | 26 | 86 | 1 010 110 | 126 |
| 23 | 010 111 | 27 | 87 | 1 010 111 | 127 |
| 24 | 011 000 | 30 | 88 | 1 011 000 | 130 |
| 25 | 011 001 | 31 | 89 | 1 011 001 | 131 |
| 26 | 011 010 | 32 | 90 | 1 011 010 | 132 |
| 27 | 011 011 | 33 | 91 | 1 011 011 | 133 |
| 28 | 011 100 | 34 | 92 | 1 011 100 | 134 |
| 29 | 011 101 | 35 | 93 | 1 011 101 | 135 |
| 30 | 011 110 | 36 | 94 | 1 011 110 | 136 |
| 31 | 011 111 | 37 | 95 | 1 011 111 | 137 |
| 32 | 100 000 | 40 | 96 | 1 100 000 | 140 |
| 33 | 100 001 | 41 | 97 | 1 100 001 | 141 |
| 34 | 100 010 | 42 | 98 | 1 100 010 | 142 |
| 35 | 100 011 | 43 | 99 | 1 100 011 | 143 |
| 36 | 100 100 | 44 | 100 | 1 100 100 | 144 |
| 37 | 100 101 | 45 | 101 | 1 100 101 | 145 |
| 38 | 100 110 | 46 | 102 | 1 100 110 | 146 |
| 39 | 100 111 | 47 | 103 | 1 100 111 | 147 |
| 40 | 101 000 | 50 | 104 | 1 101 000 | 150 |
| 41 | 101 001 | 51 | 105 | 1 101 001 | 151 |
| 42 | 101 010 | 52 | 106 | 1 101 010 | 152 |
| 43 | 101 011 | 53 | 107 | 1 101 011 | 153 |
| 44 | 101 100 | 54 | 108 | 1 101 100 | 154 |
| 45 | 101 101 | 55 | 109 | 1 101 101 | 155 |
| 46 | 101 110 | 56 | 110 | 1 101 110 | 156 |
| 47 | 101 111 | 57 | 111 | 1 101 111 | 157 |
| 48 | 110 000 | 60 | 112 | 1 110 000 | 160 |
| 49 | 110 001 | 61 | 113 | 1 110 001 | 161 |
| 50 | 110 010 | 62 | 114 | 1 110 010 | 162 |
| 51 | 110 011 | 63 | 115 | 1 110 011 | 163 |
| 52 | 110 100 | 64 | 116 | 1 110 100 | 164 |
| 53 | 110 101 | 65 | 117 | 1 110 101 | 165 |
| 54 | 110 110 | 66 | 118 | 1 110 110 | 166 |
| 55 | 110 111 | 67 | 119 | 1 110 111 | 167 |
| 56 | 111 000 | 70 | 120 | 1 111 000 | 170 |
| 57 | 111 001 | 71 | 121 | 1 111 001 | 171 |
| 58 | 111 010 | 72 | 122 | 1 111 010 | 172 |
| 59 | 111 011 | 73 | 123 | 1 111 011 | 173 |
| 60 | 111 100 | 74 | 124 | 1 111 100 | 174 |
| 61 | 111 101 | 75 | 125 | 1 111 101 | 175 |
| 62 | 111 110 | 76 | 126 | 1 111 110 | 176 |
| 63 | 111 111 | 77 | 127 | 1 111 111 | 177 |
You can verify any of these values using our binary to octal converter.
Converting Octal Back to Binary
The reverse process -- octal to binary -- is equally straightforward. Simply replace each octal digit with its 3-bit binary equivalent.
Step-by-Step Reverse Process
- Write down the octal number. Remove any prefix notation (such as a leading
0in C/C++ or0oin Python). - Replace each octal digit with its 3-bit binary value. Use the same 8-entry lookup table from above.
- Concatenate the groups. The result is the full binary representation.
- Remove leading zeros (optional) to get the minimal binary form.
Worked Example: Octal 375 to Binary
Octal input: 375
- 3 = 011
- 7 = 111
- 5 = 101
Result: 011111101 or, dropping the leading zero, 11111101 (decimal 253)
Worked Example: Octal 52 to Binary
Octal input: 52
- 5 = 101
- 2 = 010
Result: 101010 (decimal 42)
This bidirectional simplicity is a direct consequence of the 2³ = 8 relationship. The conversion is lossless, exact, and requires no arithmetic.
Programming Examples
Python
Python provides built-in support for both octal and binary:
JavaScript
JavaScript uses parseInt() and .toString() for base conversions:
C
C requires a manual approach since there is no built-in base conversion for strings:
All three implementations produce identical results. The manual grouping method mirrors exactly what you do when converting by hand, while the built-in functions (Python's oct(), JavaScript's .toString(8)) handle the grouping internally.
Practical Application: Unix/Linux File Permissions
The most visible everyday use of octal numbers in modern computing is Unix/Linux file permissions. If you have ever typed chmod 755 script.sh in a terminal, you have used binary-to-octal conversion -- whether you realized it or not.
How Unix Permissions Work
Every file and directory in a Unix-like system has three sets of permissions:
- Owner (user who created the file)
- Group (users in the file's group)
- Others (everyone else)
Each set has three permission flags:
| Permission | Symbol | Binary Bit | Value |
|---|---|---|---|
| Read | r | 1 | 4 |
| Write | w | 1 | 2 |
| Execute | x | 1 | 1 |
Each set of three permissions maps to exactly 3 binary bits, which maps to exactly one octal digit. This is not a coincidence -- octal was chosen specifically because it aligns perfectly with the 3-bit permission groups.
Decoding chmod 755
The octal number 755 breaks down as:
| Who | Octal | Binary | Permissions | Meaning |
|---|---|---|---|---|
| Owner | 7 | 111 | rwx | Read + Write + Execute |
| Group | 5 | 101 | r-x | Read + Execute |
| Others | 5 | 101 | r-x | Read + Execute |
So chmod 755 sets the full binary permission mask to 111 101 101, granting the owner full control while allowing everyone else to read and execute but not modify the file.
Common Permission Values
| Octal | Binary | Symbolic | Typical Use |
|---|---|---|---|
| 777 | 111 111 111 | rwxrwxrwx | Full access for everyone (risky) |
| 755 | 111 101 101 | rwxr-xr-x | Executable scripts, directories |
| 750 | 111 101 000 | rwxr-x--- | Group-accessible executables |
| 700 | 111 000 000 | rwx------ | Private executables |
| 644 | 110 100 100 | rw-r--r-- | Regular files (web content) |
| 600 | 110 000 000 | rw------- | Private files (SSH keys) |
| 400 | 100 000 000 | r-------- | Read-only (certificates) |
Understanding binary-to-octal conversion makes chmod values intuitive rather than mysterious.
Octal in Computing History and Modern Usage
Historical Significance
Octal notation was dominant in early computing for a practical reason: many early computers used word sizes that were multiples of three. The PDP-8 (12-bit words), the UNIVAC 1108 (36-bit words), and the IBM 7090 (36-bit words) all had architectures where octal was the natural compact notation. A 12-bit word maps cleanly to four octal digits. A 36-bit word maps to twelve octal digits.
The octal prefix 0 in the C programming language is a direct heritage of this era -- Ken Thompson and Dennis Ritchie developed C on a PDP-11, and octal notation was the standard at Bell Labs. This convention persists in C, C++, Java, and other languages to this day (e.g., 0755 in C is octal 755, decimal 493).
Why Hex Largely Replaced Octal
The shift from octal to hexadecimal occurred as the industry standardized on 8-bit bytes. Since 8 is not divisible by 3, a single byte does not map cleanly to a whole number of octal digits (it requires 2.67 octal digits). In contrast, one byte maps to exactly two hex digits. As byte-addressable architectures (Intel 8080, Zilog Z80, Motorola 68000) became dominant, hexadecimal became the preferred notation.
Where Octal Is Still Used Today
Despite hexadecimal's dominance, octal remains relevant in several areas:
- Unix/Linux file permissions:
chmod,umask, andstatall use octal - C/C++ octal literals: Any integer literal with a leading
0(e.g.,0755) is interpreted as octal - Python octal literals: The
0oprefix (e.g.,0o755) - Escape sequences: Some programming languages use
\nnn(octal) for character escapes - Aviation transponder codes: Aircraft squawk codes are four-digit octal numbers (0000-7777)
- Legacy systems: Mainframe code and documentation from the 1960s-1970s frequently use octal
Frequently Asked Questions
How do you convert binary to octal?
Group the binary digits into sets of three from right to left, padding the leftmost group with leading zeros if necessary. Then replace each 3-bit group with its octal equivalent (000=0, 001=1, 010=2, 011=3, 100=4, 101=5, 110=6, 111=7). For example, binary 11010110 groups as 011 010 110, which converts to octal 326.
Why does binary-to-octal conversion use groups of 3?
Because 8 = 2³. The octal base (8) is the third power of the binary base (2), which means exactly three binary bits are needed to represent all possible values of a single octal digit (0 through 7). This mathematical relationship makes the conversion a direct substitution with no arithmetic required.
What is binary 11111111 in octal?
Binary 11111111 (decimal 255) converts to octal 377. Grouping from the right: 011 111 111, which gives 3-7-7. This is the maximum value of one byte in octal notation.
How do you handle binary numbers that are not a multiple of 3 digits?
Pad the leftmost group with leading zeros. For example, binary 10011 has 5 digits. Grouped from the right: 10 011. Pad the left group: 010 011. Convert: 2-3. The result is octal 23. Adding leading zeros does not change the numerical value.
What is the difference between octal and hexadecimal?
Octal is base-8 (digits 0-7) and each digit represents 3 binary bits. Hexadecimal is base-16 (digits 0-9, A-F) and each digit represents 4 binary bits. Hex is more common in modern computing because it aligns with 8-bit bytes (2 hex digits = 1 byte), while octal is still used for Unix file permissions and in legacy systems.
Why does chmod use octal numbers?
Each file permission set (owner, group, others) consists of three binary flags: read (r), write (w), and execute (x). Three binary flags map directly to one octal digit (since 2³ = 8). This makes octal the most natural and compact notation for expressing Unix permissions. For example, rwxr-xr-x = 111 101 101 = 755 in octal.
Can you convert octal to binary directly?
Yes -- simply replace each octal digit with its 3-bit binary equivalent. Octal 47 becomes 100 111 (binary). The process is the exact reverse of binary-to-octal conversion and is equally mechanical. No division or multiplication is needed.
What is octal 777 in binary and decimal?
Octal 777 equals binary 111 111 111 (nine 1-bits) and decimal 511. In Unix permissions, chmod 777 grants full read, write, and execute permissions to the owner, group, and all other users.
Summary
Binary-to-octal conversion relies on one foundational fact: 8 = 2³, so each octal digit maps to exactly three binary bits. Whether you are converting a 3-bit value or a 64-bit address, the algorithm is always the same: group into threes from the right, pad the leftmost group, and substitute.
The key takeaways from this guide:
- Group binary digits into 3-bit chunks from the right and replace each group with its octal digit (000-111 maps to 0-7)
- Pad the leftmost group with zeros if the total number of bits is not a multiple of three
- Unix file permissions are the most common modern use of octal, with each rwx triplet mapping to one octal digit
- Programming languages provide built-in conversion: Python's
oct(int(x, 2)), JavaScript'sparseInt(x, 2).toString(8), and manual grouping in C - The reverse conversion (octal to binary) works by replacing each octal digit with its 3-bit binary value
- Octal was historically dominant on systems with word sizes divisible by 3, but hexadecimal took over as 8-bit bytes became standard
Ready to practice? Use our free binary to octal converter to convert any binary value to octal instantly, with step-by-step 3-bit group visualization and automatic padding.