Decimal to Octal Converter

Convert non-negative integers between decimal (base 10) and octal (base 8).

Convert chmod ready Multi-base
Rate this calculator

Decimal ↔ Octal

Base-10 ↔ base-8 conversion

Instructions — Decimal to Octal Converter

1

Pick a direction

Toggle between "Dec → Oct" and "Oct → Dec". The input accepts decimal integers in one direction, and octal strings (digits 0–7 only) in the other.

2

Type or pick a value

Enter the number to convert. Quick picks load common values — 8 (one octal place), 64 (chmod 100), 493 (chmod 755), 420 (chmod 644), 4095 (octal 7777).

3

Optional 0o prefix

Add the 0o prefix for Python 3 / modern C-style octal literals. The result panel also shows binary and hexadecimal for cross-base reference.

Formulas

Octal uses eight digits (0–7). The conversion is repeated division by 8 for decimal-to-octal, and a positional sum of powers of 8 for octal-to-decimal.

Decimal to octal (positional)
$$ N = \sum_{i=0}^{k} d_i \cdot 8^{i} $$
The decimal value N equals the sum of each octal digit times the corresponding power of 8. The conversion finds the digits.
Repeated division by 8
$$ N = q_0 \cdot 8 + r_0,\;\; q_0 = q_1 \cdot 8 + r_1,\;\; \ldots $$
Divide N by 8, keep the remainder, divide the quotient again. Continue until the quotient is zero. Read the remainders bottom-up.
Worked example: 64 → 100
$$ 64 \div 8 = 8\,r\,0;\;\; 8 \div 8 = 1\,r\,0;\;\; 1 \div 8 = 0\,r\,1 $$
64 in decimal is 100 in octal (read 1, 0, 0 from the bottom up).
Octal to decimal
$$ N = d_k \cdot 8^{k} + d_{k-1} \cdot 8^{k-1} + \dots + d_0 $$
Multiply each octal digit by the appropriate power of 8 and sum. Example: 755 octal = 7 × 64 + 5 × 8 + 5 = 493 decimal.
Three-bit grouping
$$ 1\,\text{octal digit} = 3\,\text{bits} $$
One octal digit encodes exactly three bits — which is why Unix permission groups (read/write/execute) map to one octal digit each.
Maximum value per width
$$ \text{max} = 8^{n} - 1 $$
n octal digits can represent values up to 8^n − 1. So 2 digits → 63, 3 digits → 511, 4 digits → 4,095, 6 digits → 262,143.

Reference

Decimal-octal quick table
DecimalOctalBinaryNote
8101000One octal place
162010000
6410010000008² — three octal digits
2564002⁸One byte
4206449-bit chmodchmod 644 = rw-r--r--
4937559-bit chmodchmod 755 = rwxr-xr-x
5117779 × 1chmod 777 = full open
10001750
4095777712 bits8⁴ − 1

Octal digit map

OctalDecimalBinary
00000
11001
22010
33011
44100
55101
66110
77111

Article — Decimal to Octal Converter

The Decimal to Octal Converter

Octal is the base-8 number system with digits 0–7. The decimal to octal conversion is repeated division by 8, reading remainders bottom-up. 64 decimal becomes 100 octal; 493 decimal becomes 755 octal (the Unix chmod value for rwxr-xr-x). Each octal digit encodes exactly three bits.

Octal survives in modern computing mostly through Unix file permissions and a handful of escape sequences in older programming languages. Hexadecimal long ago took over from octal for byte-level work, but octal still hangs on where the three-bit grouping happens to match real-world structures — and chmod is the canonical case.

What is octal?

Octal is a positional number system with eight digits (0, 1, 2, 3, 4, 5, 6, 7). The right-most column is the 1s column, the next is the 8s column, the next the 64s column, the next the 512s column, and so on — each position is a power of 8.

Octal aligned naturally with the early generations of computers that used 12-, 24-, or 36-bit words, because those word sizes divide cleanly by 3. One octal digit covers three bits, so a 36-bit word is exactly 12 octal digits. Modern byte-oriented machines (8, 16, 32, 64 bits) divide by 4 rather than 3, which is why hex took over.

Did you know

The PDP-8, one of the most popular minicomputers ever made (over 50,000 sold from 1965 onward), used 12-bit words and was documented entirely in octal. Programmers wrote octal machine code by hand, and the indicator lights on the front panel were arranged in groups of three to match the octal digits.

The decimal to octal algorithm

The standard algorithm is repeated division by 8.

Decimal to octal steps
step 1 divide N by 8, keep remainder
step 2 repeat on quotient until 0
step 3 read remainders bottom-up
step 4 all remainders are 0–7

Worked example with 342 decimal: 342 ÷ 8 = 42 r 6; 42 ÷ 8 = 5 r 2; 5 ÷ 8 = 0 r 5. Reading bottom-up gives 526 octal. Check: 5 × 64 + 2 × 8 + 6 = 320 + 16 + 6 = 342. The same algorithm scales to any non-negative integer.

Octal to decimal (positional sum)

The reverse is a positional sum. From right to left, position values are 1, 8, 64, 512, 4,096, 32,768, 262,144 (the powers of 8). Multiply each digit by its position value and add.

Worked example with 755 octal: 7 × 64 + 5 × 8 + 5 × 1 = 448 + 40 + 5 = 493 decimal. Same with 1234 octal: 1 × 512 + 2 × 64 + 3 × 8 + 4 × 1 = 512 + 128 + 24 + 4 = 668 decimal. The full algorithm is identical to the decimal interpretation everyone learns in school — only the base differs.

Octal in Unix chmod permissions

Unix permissions are the headline use case for octal today. Each file has nine permission bits — read, write, execute for the owner, group, and others. Three bits per group map exactly to one octal digit (0–7). The full set fits in three octal digits.

chmod 644
rw-r--r--
read-write owner, read-only group / others
chmod 755
rwxr-xr-x
full owner, read-exec group / others

The digit values translate directly: 7 = rwx (4 + 2 + 1), 6 = rw- (4 + 2), 5 = r-x (4 + 1), 4 = r-- (4), and so on. Memorising those eight combinations covers nearly every chmod you will ever need to read or write.

  • 7 = rwx — full access
  • 6 = rw- — read and write, no execute
  • 5 = r-x — read and execute, no write
  • 4 = r-- — read only
  • 3 = -wx — write and execute (rare)
  • 2 = -w- — write only (rare)
  • 1 = --x — execute only (special case)
  • 0 = --- — no access

Octal in C, Python, and shell

Programming languages handle octal literals in three styles. Old C and shell use a plain leading zero (0755). Python 3 and modern C/C++ use the 0o prefix (0o755). A few older Pascal-style languages used a trailing letter or another marker. The leading-zero style remains the most common in shell scripts and historic C, but it is the most error-prone — typing 0755 thinking decimal gives you 493.

Octal also shows up in C/Python escape sequences. A backslash followed by one to three octal digits inside a string literal stands for the byte with that value. "\101" is the letter A (octal 101 = decimal 65 = ASCII A). The same idea works in Python 2 and Bash echo. Modern code more often uses \x (hex) or \u (Unicode) for the same purpose.

Tip

If you find yourself converting between chmod permissions and bit patterns often, memorise the eight combinations once. After that you read chmod 755 as 111-101-101 by eye, and you can write any permission set without consulting a table.

Octal vs hexadecimal — which to use

For byte-level work, hex wins. A byte (8 bits) is exactly two hex digits (00–FF), but it spans three octal digits (000–377) and wastes a third of the third digit. Modern memory dumps, colour codes, network protocols, and crypto values all use hex for that reason.

Octal wins only when the underlying structure is naturally divisible by 3. Unix permissions are the textbook case. A few legacy file formats and embedded systems also use octal. Outside those niches, hex is the default modern radix.

A short history of octal in computing

Octal dominated computing documentation from the 1950s through the 1970s. The IBM 704 and 709 (36-bit), the CDC 6600 (60-bit), the PDP-7, PDP-8, and PDP-10 series (12-, 18-, and 36-bit) all used octal as the standard radix for memory addresses, machine code listings, and front-panel toggles. Whole generations of programmers learned octal first and decimal second.

The shift to byte-oriented machines began with the IBM System/360 in 1964, which standardised on 8-bit bytes and 32-bit words. Hex maps to bytes; octal does not. By the mid-1970s most new systems documented memory in hex, and octal retreated to the few applications where three-bit grouping still made sense.

Common decimal to octal mistakes

Most octal errors are about prefix handling and digit range.

  • leading zero in C — 0755 is octal 493 decimal, not decimal 755
  • using digits 8 or 9 — only 0–7 are valid octal digits
  • treating chmod as decimal — chmod 755 is octal; chmod 1755 in decimal means something else entirely
  • mixing 0o with 0 prefix — Python 3 requires 0o; bare leading zero is a syntax error
  • letting any digit exceed 7 — 8 in octal is invalid; the next value after 7 is 10 (octal)
  • byte alignment — 1 byte is not 1 octal digit; you need three octal digits (000–377) to span a byte's 0–255 range
chmod 777 is rarely the right answer

Setting chmod 777 grants full read/write/execute access to everyone on the system. It is the simplest way to fix "permission denied" errors and the simplest way to introduce a security hole. Default to 644 for files and 755 for directories and executables. Use 777 only as a deliberate, scoped choice — never as a fix-all.

FAQ

64 (dec) = 100 (octal). The math: 64 ÷ 8 = 8 r 0; 8 ÷ 8 = 1 r 0; 1 ÷ 8 = 0 r 1. Read the remainders bottom-up to get 100. Because 8² = 64, the result is exactly 1-0-0.
0o is the Python 3 octal prefix. It tells the parser that the digits are base 8. Older C used a plain leading zero (0755) for the same purpose, but Python 3 and recent C++ require 0o to avoid ambiguity with decimal.
Each Unix file has three permission groups — owner, group, others — and each group has three bits — read, write, execute. Three bits map cleanly to one octal digit (0–7), so the full nine-bit permission set fits in exactly three octal digits. chmod 755 = rwx for owner, r-x for group, r-x for others.
755 octal = 493 decimal. The math: 7 × 64 + 5 × 8 + 5 = 448 + 40 + 5 = 493. Nobody writes chmod in decimal because the octal form lines up with the permission bits one-to-one.
Replace each octal digit with its 3-bit binary equivalent. 755 becomes 111-101-101 = 111101101. No arithmetic required. The mapping is fixed: 0 → 000, 1 → 001, … 7 → 111.
Yes, but mostly in two places: Unix file permissions (chmod) and string escape sequences in some languages (\101 = letter A in C-style strings). Modern programming has otherwise moved to hexadecimal because hex aligns with bytes (8 bits / 2 hex digits) while octal does not.
777 octal = 511 decimal. That is 8³ − 1, the largest value you can store in three octal digits. In a chmod context, 777 means full read/write/execute access for owner, group, and others — and is usually a security mistake.
The pure positional system has no sign bit, so plain octal handles non-negative integers only. Two's complement representation works at the bit level rather than the digit level, and most octal display tools (e.g. od on Unix) treat values as unsigned. For signed values, switch to hex or decimal.